Fire up 'xev' from the terminal, press the key you wish to know the code for, and then check the output xev gives you.
You'll see something like this:
KeyPress event, serial 30, synthetic NO, window 0x1800001,
root 0x46, subw 0x1800002, time 1544556304, (23,45), root:(342,386),
state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
It's the bit after 'keysym 0xffex2' (Shift_R) that tells you the valid key code, and this is acceptable to put in your keymap/kernel.map file.
It works the same when pressing two keys (e.g, the 'Function' and '?.>' keys), telling you what each combination results in. (In that case 'Mode_switch', and '>').
I know I tend to over-simplify things, so I apologise in advance
Hope this helps