Vim: What is a key code

vim

Sorry for the blatant display of ignorance, but what exactly is a key code? I'm setting the timeout length in my vimrc, and reading about timeoutlen and ttimeoutlen. There's a distinction between key-mappings and key codes, but I'm not clear what a key code is.

Best Answer

On my keyboard, when I type in QWERTY, when I press the "H" key, I get an "H." In contrast, when I'm in Dvorak mode and I press the "H" key, I get a "D." The keyboard is sending the exact same key-code to the computer, but the computer maps the key to a different letter based on the typing mode (in this case, QWERTY vs Dvorak).

In this example, the key-code for the "H" key on the keyboard is 0x48, or "72" in decimal. The key mapping is determined by the software (the OS, the text editor, the game, etc) to determine what key-code maps to what function.

Related Question