Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Can somebody please provide the key codes for these keys:

  • Caps Lock
  • Left Shift
  • Left Control
  • Option key
  • FN

The key code I'm talking about is something along the lines of \<Esc>[200~, although I have no idea what that outputs. :P

Thanks! I need this for remapping some keys in Vim, tmux etc.

share|improve this question
2  
showkey can probably tell you that –  charlesbridge Jan 7 '13 at 12:30
    
@charlesbridge OK, do you have an example of how you would use showkey? Thanks! –  Greduan Jan 7 '13 at 13:30
add comment

2 Answers

showkey will dump out the code for any key you press. You probably want showkey -s (although no options works well, too). I pressed SHIFT (the 0x9a is ENTER coming back up):

$showkey -s
kb mode was in UNICODE
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)
0x9a
0x2a 0xaa

Like the warning says, don't try it under xterm (or any X program). It needs a real tty to read from.

share|improve this answer
    
Although that outputs it in a hexadecimal code, right? Would it work if it outputs like that? I need it for stuff like t_SI and stuff like that in Vim. Would that work? –  Greduan Jan 7 '13 at 16:16
add comment

These keys are not sent to terminals. Only printable characters, function keys, and combinations of these keys with modifiers are sent to terminal applications (most function keys are sent in the form of escape sequences beginning with ESC [). Modifier keys (like CapsLock, Shift, etc.) are visible to GUI applications, but not to terminal applications. You won't be able to detect a press of these keys in vim or tmux. See What is bash's meta key? for more background.

With the Fn on many laptops, it's even worse: this key is handled by the BIOS and not even visible to the operating system.

share|improve this answer
    
Ah I see, that makes sense. Thanks for your answer, will see if I can find a way to do this then. :) –  Greduan Jan 8 '13 at 1:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.