[Up][Next] | Reference for unit 'keyboard' (#rtl)

## Unix specific notes

On Unix, applications run on a "terminal", and the application writes to the screen and reads from the keyboard by communicating with the terminal. Unix keyboard handling is mostly backward compatible with the DEC VT100 and VT220 terminals from tens of years ago. The VT100 and VT220 had very different keyboards than todays PC's and this is where the problems start. To make it worse the protocol of both terminals has not been very well designed.

Because of this, the keyboard unit on Unix operating systems does a best effort to provide keyboard functionality. An implementation with full keyboard facilities like on other operating systems is not possible.

The exception is the Linux kernel. The terminal emulation of the Linux kernel is from a PC keyboard viewpoint hopeless as well, but unlike other terminal emulators it is configurable. On the Linux console, the Free Pascal keyboard unit tries to implement full functionality.

Users of applications using the keyboard unit should expect the following:

- Full functionality on the Linux console. It must be the bare console, SSH into another machine will kill the full functionality.
- Limited functionality otherwise.

Notes about Linux full functionality:

- The keyboard is reprogrammed. If the keyboard is for whatever reason not restored in its original state, please load your keymap to reinitialize it.
- Alt+function keys generate keycodes for those keys. To switch virtual consoles, use ctrl+alt+function key.
- Unlike what you're used to with other Unix software, escape works as you intuitively expect, it generates the keycode for an escape key without a delay.

The limited functionality does include these quirks:

- Escape must be pressed two times before it has effect.

- On the Linux console, when the users runs the program by logging into another machine:

  - Shift+F1 and Shift+F12 will generate keycodes for F11 and F12.
  - Shift+arrow keys, shift+ins, shift+del, shift+home, shift+end do not work. The same is true about the control and alt combinations.
  - Alt+function keys will switch virtual consoles instead of generating the right key sequences.
  - Ctrl+function keys will generate the keycodes for the function keys without ctrl

- In Xterm:

  - Shift+insert pastes the x clipboard, no keycode will be generated.

- In Konsole:

  - Shift+insert pastes the x clipboard, no keycode will be generated.
  - Shift+arrow keys doesn't work, nor does ctrl+arrow keys

If you have a non-standard terminal, some keys may not work at all. When in limited functionality mode, the user can work around using an escape prefix:

- Esc+1 = F1, Esc+2 = F2.
- Esc before another key is equal to alt+key.

In such cases, if the terminal does output an escape sequence for those keys, please submit a bug report so we can add them.

Documentation generated on: May 14 2021