Is it possible in the Unix terminal to change some of the keyboard keys?
For example: when I press
_ gets printed?
If this is indeed possible, how do I go about doing that?
I'm on Ubuntu.
To quote from here:
You can create your own map and store it in your home directory (i.e. ~/.Xmodmap). Print the current keymap table into a configuration file:
xmodmap -pke > ~/.Xmodmap
Make the desired changes to ~/.Xmodmap and then test the new configuration with:
To activate your custom table when starting Xorg add the following:
~/.xinitrc if [ -f $HOME/.Xmodmap ]; then /usr/bin/xmodmap $HOME/.Xmodmap fi
Alternatively, edit the global startup script
You can also make temporary changes for the current session. For example:
xmodmap -e "keycode 46 = l L l L lstroke Lstroke lstroke" xmodmap -e "keysym a = e E"
man xmodmap for more details.
To clarify: the
xmodmap ~/.Xmodmap may be used in many places, not just when starting Xorg. For example, I have these two functions in my ~/.bashrc:
# map caps to esc
xmodmap -e "clear lock"
xmodmap -e "keycode 0x42 = Escape"
echo mapcaps: caps-lock set to Escape via xmodmap
xmodmap -e "keycode 0x42 = Caps_Lock"
xmodmap -e "add lock = Caps_Lock"
echo unmapcaps: caps-lock set to caps-lock via xmodmap
This is so I can dynamically map Caps to Esc.
Really there is no limitation. Feel free to call xmodmap from ~/.xinitrc, ~/.bash_profile, from a custom script, etc.
To be honest I have never tried to do what you are trying. I have added alternate key bindings (key combination) for a terminal (non-X) before though.
You can see your key bindings with:
You will use the related programs to do the additional research and modifications.
For me to make the change in Slackware it is pretty easy I spent some time looking around in Ubuntu but did not find the same files
/usr/share/kbd/keymaps/i386/qwerty/*map.gz files. Though I only had access to a live booted Ubuntu system. You might fare better.
If you want to do this in the X Windowing System, you can use Xmodmap. I've never had a grip on the syntax, so find a working example, and go from there.