Getting character key code mappings in Ubuntu

Run xev from a terminal. This will give you a new window.

Place your mouse pointer in this window, type some keys and watch for results in the terminal.


In order to get a terminal print-out of all key codes and corresponding keys, run the following command in a terminal:

xmodmap -pk

It's not easy to view in a (small) terminal window, so if you want to save the output to a file, just add the command to let the terminal output be saved in a file (in your current working directory in the terminal):

xmodmap -pk > mykeyboard.txt

Full description of how to use xmodmap here.