To get the number associated with a key you just have to type 'xev' in
the terminal. However if it is assigned to a program already you have to
quit from X server and get a prompt to type 'xev'

I got the following good info from wikipedia...
[code]
Using xev

Another way to get the keycodes of your keys is to use the graphical X program "xev" (without having to switch to a console environment). With the following line you can start xev and directly grep the important parts:

38 a
27 r
54 c
43 h
153 NoSymbol
144 NoSymbol
This means that the "a", "r", "c" and "h" keys have the keycodes 38, 27, 54 and 43 and are properly bound while the media keys with the keycodes 153 and 144 have no function yet, which is indicated by "NoSymbol". If you press a key and nothing appears in the terminal, this means that the kernel doesn't see that key or that it is not mapped.[/code]