Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Post History
There are quite a few layers and protocols involved in keyboard input. At the lowest layer, you have the USB HID protocol (https://www.usb.org/document-library/device-class-definition-hid-111 and ...
#2: Post edited
- There are quite a few layers and protocols involved in keyboard input.
- At the lowest layer, you have the USB HID protocol (https://www.usb.org/document-library/device-class-definition-hid-111 and https://usb.org/document-library/hid-usage-tables-16). In times of yore, when the Earth was young and primordial beasts roamed the forests, there were the PS/2 and other protocols. Ben Eater has some nice videos on PS/2 and USB keyboards at Youtube (https://youtu.be/7aXbh9VUB3U?si=-WdEcrantNi7LbzX, https://youtu.be/wdgULBpRoXk?si=Xh8JluZ-JATTG3Pk and
- https://youtu.be/2lPzTU-3ONI?si=LwNg-XjOll5Ph62_).
- Then the operating system may have another protocol, such as evdev on Linux (https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h).
- The display server/window system will have its own protocol, e.g. wl_keyboard (https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard) in Wayland, or the KeyPress, KeyRelease and KeymapNotify events in X11 (https://tronche.com/gui/x/xlib/).
- Then there are input methods, which not only provide things such as proper support for CJK languages, which need many more symbols than keys are on a keyboard, but also support things such as predictive input (https://mike-fabian.github.io/ibus-typing-booster/). The situation at the moment in Linux is quite complex. Wayland (https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/39) has protocols to communicate between the input method framework and the compositor (`input-method-*`), and to communicate between client applications and the compositor (`text-input-*`), and there are currently different versions of each in use. X11 has XIM (https://www.x.org/releases/X11R7.6/doc/libX11/specs/XIM/xim.html), but toolkits such as GTK and Qt provide their own input method support. Short version: prefer Wayland protocols over toolkit support, prefer toolkit support over XIM.
- And finally we arrive at terminals and terminal emulators. These tend to support some variation over the DEC VT100 (and above) protocol (https://vt100.net/docs/vt100-ug/chapter3.html#S3.1). As can be seen on xterm docs (https://invisible-island.net/xterm/ctlseqs/ctlseqs.html), the situation got quite complex over time, with keyboards having/not having different keys, and different terminal emulators supporting them in different ways. In more recent times there have been extensions to all this, such as xterm's ModifyOtherKeys, Leonerd's fixterms (https://www.leonerd.org.uk/hacks/fixterms/), and the Kitty keyboard protocol (https://sw.kovidgoyal.net/kitty/keyboard-protocol/).
- More links:
- https://en.m.wikipedia.org/wiki/Scancode
- https://wiki.archlinux.org/title/Keyboard_input
- https://tomscii.sig7.se/zutty/doc/KEYS.html
- There are quite a few layers and protocols involved in keyboard input.
- At the lowest layer, you have the USB HID protocol (https://www.usb.org/document-library/device-class-definition-hid-111 and https://usb.org/document-library/hid-usage-tables-16). In times of yore, when the Earth was young and primordial beasts roamed the forests, there were the PS/2 and other protocols. Ben Eater has some nice videos on PS/2 and USB keyboards at Youtube (https://youtu.be/7aXbh9VUB3U?si=-WdEcrantNi7LbzX, https://youtu.be/wdgULBpRoXk?si=Xh8JluZ-JATTG3Pk and
- https://youtu.be/2lPzTU-3ONI?si=LwNg-XjOll5Ph62_).
- Then the operating system may have another protocol, such as evdev on Linux (https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h).
- The display server/window system will have its own protocol, e.g. wl_keyboard (https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard) in Wayland, or the KeyPress, KeyRelease and KeymapNotify events in X11 (https://tronche.com/gui/x/xlib/).
- Then there are input methods, which not only provide things such as proper support for CJK languages, which need many more symbols than keys are on a keyboard, but also support things such as predictive input (https://mike-fabian.github.io/ibus-typing-booster/). The situation at the moment in Linux is quite complex. Wayland (https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/39) has protocols to communicate between the input method framework and the compositor (`input-method-*`), and to communicate between client applications and the compositor (`text-input-*`), and there are currently different versions of each in use. X11 has XIM (https://www.x.org/releases/X11R7.6/doc/libX11/specs/XIM/xim.html), but toolkits such as GTK and Qt provide their own input method support. Short version: prefer Wayland protocols over toolkit support, prefer toolkit support over XIM.
- And finally we arrive at terminals and terminal emulators. These tend to support some variation over the DEC VT100 (and above) protocol (https://vt100.net/docs/vt100-ug/chapter3.html#S3.1). As can be seen on xterm docs (https://invisible-island.net/xterm/ctlseqs/ctlseqs.html), the situation got quite complex over time, with keyboards having/not having different keys, and different terminal emulators supporting them in different ways. In more recent times there have been extensions to all this, such as xterm's ModifyOtherKeys, Leonerd's fixterms (https://www.leonerd.org.uk/hacks/fixterms/), and the Kitty keyboard protocol (https://sw.kovidgoyal.net/kitty/keyboard-protocol/).
- More links:
- https://en.m.wikipedia.org/wiki/Scancode
- https://wiki.archlinux.org/title/Keyboard_input
- https://www.csslayer.info/wordpress/linux/how-to-make-your-application-support-input-method-under-linux/
- https://tomscii.sig7.se/zutty/doc/KEYS.html
#1: Initial revision
There are quite a few layers and protocols involved in keyboard input. At the lowest layer, you have the USB HID protocol (https://www.usb.org/document-library/device-class-definition-hid-111 and https://usb.org/document-library/hid-usage-tables-16). In times of yore, when the Earth was young and primordial beasts roamed the forests, there were the PS/2 and other protocols. Ben Eater has some nice videos on PS/2 and USB keyboards at Youtube (https://youtu.be/7aXbh9VUB3U?si=-WdEcrantNi7LbzX, https://youtu.be/wdgULBpRoXk?si=Xh8JluZ-JATTG3Pk and https://youtu.be/2lPzTU-3ONI?si=LwNg-XjOll5Ph62_). Then the operating system may have another protocol, such as evdev on Linux (https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h). The display server/window system will have its own protocol, e.g. wl_keyboard (https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_keyboard) in Wayland, or the KeyPress, KeyRelease and KeymapNotify events in X11 (https://tronche.com/gui/x/xlib/). Then there are input methods, which not only provide things such as proper support for CJK languages, which need many more symbols than keys are on a keyboard, but also support things such as predictive input (https://mike-fabian.github.io/ibus-typing-booster/). The situation at the moment in Linux is quite complex. Wayland (https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/39) has protocols to communicate between the input method framework and the compositor (`input-method-*`), and to communicate between client applications and the compositor (`text-input-*`), and there are currently different versions of each in use. X11 has XIM (https://www.x.org/releases/X11R7.6/doc/libX11/specs/XIM/xim.html), but toolkits such as GTK and Qt provide their own input method support. Short version: prefer Wayland protocols over toolkit support, prefer toolkit support over XIM. And finally we arrive at terminals and terminal emulators. These tend to support some variation over the DEC VT100 (and above) protocol (https://vt100.net/docs/vt100-ug/chapter3.html#S3.1). As can be seen on xterm docs (https://invisible-island.net/xterm/ctlseqs/ctlseqs.html), the situation got quite complex over time, with keyboards having/not having different keys, and different terminal emulators supporting them in different ways. In more recent times there have been extensions to all this, such as xterm's ModifyOtherKeys, Leonerd's fixterms (https://www.leonerd.org.uk/hacks/fixterms/), and the Kitty keyboard protocol (https://sw.kovidgoyal.net/kitty/keyboard-protocol/). More links: https://en.m.wikipedia.org/wiki/Scancode https://wiki.archlinux.org/title/Keyboard_input https://tomscii.sig7.se/zutty/doc/KEYS.html