Here is a still incomplete patch for this, renamed from "physical keyboard events", following up to https://lists.gnu.org/archive/html/emacs-devel/2024-11/msg00085.html It provides events for press/release of keys, independently of the normal keyboard events. These events are bound int the special-event-map. Some lisp is included to implement detection of multiple tapping on keys, and running commands or simulating modifiers. Currently, only modifier keys are available, because other keys would send their own normal event. This could change when an use case for other keys appears. To provide events for 'logical' modifiers Ctrl, Meta, etc., now there is a new event low-level-modifier, in addition to low-level-key. If you press Shift_L, two events will be generated, one for 'shift as low-level-modifier, and one for 'lshift as low-level-key. The lisp part handles those events separately. I added a variable that enables/disables everything, enable-low-level-key-events. This are some of Po Lu's notes on the previous patch: > [...] Emacs must not depend on XKB for such a basic feature. Fixed. > Please find some means of generating such events by saving them into the > keyboard event buffer defined in handle_ome_xevent. As we may generate two events, that is not possible. > x_filter_events is not the proper location for this call. It is only > invoked to filter an event through the active GTK or X input method > context, and it is not invoked if Emacs is configured not to open input > method contexts, or they are unavailable by happenstance. Done. If XINPUT is enabled, the XI_KeyPress event used, over the gtk one. If not, the gtk event is used unless there is no input method. In this case KeyPress event is used. The pgtk version is not updated.