|
Keycodes
Character sequences sent by keys in mintty
Keyboard layoutThe Windows keyboard layout is used to translate alphanumeric and symbol key presses into characters, which means that the keyboard layout can be switched using the standard Windows mechanisms for that purpose. AltGr combinations, dead keys, and input method editors (IMEs) are all supported. Should the available keyboard layouts lack required features, Microsoft's Keyboard Layout Creator can be used to create custom keyboard layouts. Mintty does not implement an X11-style compose key, but the open source AllChars utility can be used to emulate one. For other keys and key combinations, mintty sends xterm keycodes, with a few minor changes and some additions. Below, Caret notation is used to show control characters. Alt and MetaAs is customary with PC keyboards, the Alt key acts as the so-called Meta modifier. When it is held down while pressing a key or key combination, the keycode is prefixed with an escape character, unless noted otherwise in the keycode tables in the following sections. Encoding the meta modifier by setting the top bit of a character instead of prefixing it with the escape character is not supported, because that does not work for character codes beyond 7-bit ASCII. AltGrThe right Alt key, which is labelled AltGr on most non-US keyboards, allows to type additional characters on many keyboard layouts. When the keyboard layout does not have a keycode for an AltGr combination, the AltGr key is treated as Alt instead. The Ctrl+LeftAlt is AltGr setting allows combinations of either Ctrl key with the left Alt key to also be treated as AltGr. CtrlFor key combinations involving Ctrl, the key combination's character code without the Ctrl is looked up in the Windows keyboard layout (whereby AltGr or Shift may be involved). If the resulting character corresponds to a control character, the control character will be sent to the application. For example, Ctrl+] sends ^]. If the keyboard layout does not yield a character from the table below, the key's "virtual keycode" is tried instead, which usually corresponds to the US keyboard layout. This allows control characters to be entered when using a non-Latin keyboard layout. If Shift is held in addition to a control character combination, the corresponding character from the so-called C1 control character set is sent. The C1 control characters are shown as Unicode codepoints in the table below. How exactly C1 control characters are sent depends on the selected character encoding. In ISO-8859 encodings, they are encoded as single bytes, e.g. \x81 for U+0081. With UTF-8, they are encoded as two-byte sequences, which effectively means that the character code is prefixed with a \xC2 byte, so for example U+0081 becomes \xC2\x81. C1 codepoints that are not supported by the selected character encoding are sent by prefixing the corresponding ASCII control character with an ESC character, so U+0081 would be sent as ^[^A.
Special keysThe keys here send the usual control characters, but there are a few mintty-specific additions that make combinations with modifier keys available as separate keycodes.
Pause and Break usually share a key, whereby Ctrl has to be pressed to get the Break function. Modifier key encodingsWhere the modifier keys Shift, Alt and Ctrl are not handled as described in the sections above, they are encoded as a one-digit number that becomes part of the keycode. To obtain that number, add the numbers for each pressed modifier to 1:
For example, Shift+Ctrl would be encoded as the number 6 (1 plus 1 for Shift plus 4 for Ctrl). Modifiers are not double-counted if, for example, both Shift keys are pressed. In the following sections, modifier codes are shown as m. Number and symbol keysNumber and symbol key combinations that are not handled either by the Windows keyboard layout or by the Ctrl key processing described above, are assigned the keycodes shown here.
(These are VT220 application keypad codes with added modifier.) Cursor keysCursor keycodes without modifier keys depend on whether "application cursor key mode" (controlled by the DECCKM sequence) is enabled. Application cursor mode is ignored if any modifier keys are down, and the modifier code is inserted into the keycode as shown. By default, the Home and End keys are considered cursor keys. If VT220 keyboard mode is enabled, they are treated as editing keys instead. See the next section for their keycodes in that case.
Editing keysThere is no special application mode for the keys in the block that's usually above the arrow keys.
As mentioned in the cursor keys section, the Home and End keycodes shown here are only used if VT220 keyboard mode is enabled. Function keysF1 through F4 send numpad-style keycodes, because they emulate the four PF keys above the number pad on the VT100 terminal. The remaining function keys send codes that were introduced with the VT220 terminal.
The numbers in the keycodes really are that irregular. Only twelve function keys are usually available on a PC keyboard, but in VT220 keyboard mode, the Ctrl modifier adds 10 to the function key number, so that for example Ctrl+F3 sends the F13 keycode. MousewheelIn xterm mouse tracking modes, the mousewheel is treated is a pair of mouse buttons. However, the mousewheel can also be used for scrolling in applications such as less that do not support xterm mouse reporting but that do use the alternate screen. Under those circumstances, mousewheel events are encoded as cursor up/down and page up/down keys. See the sections on the cursor keys and editing keys for details. The number of line up/down events sent per mousewheel notch depends on the relevant Windows setting on the Wheel tab of the Mouse control panel. Page up/down codes can be sent by holding down Shift while scrolling. The Windows wheel setting can also be set to always scroll by a whole screen at a time. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||