[openbox] Key Chain Broken by Multiple Keyboards

Parke parke.nexus at gmail.com
Sat Jun 24 14:51:31 EDT 2023


On Sat, Jun 24, 2023 at 5:30 AM Steve Litt <slitt at troubleshooters.com> wrote:
> Seems to me that there's no way for keyboard2 to know you're pushing
> Alt, Ctrl or Shft on keyboard1 and vice versa.
>
> If I remember correctly a single keyboard is a matrix of switches
> connecting to an array of horizontal and vertical wires, and that's
> converted to some sort of keycode. This stuff's decoded in the
> keyboard, not in the computer, so I'd expect key combos on 2 separate
> keyboards to fail.

I believe there are multiple layers.

Each keyboard outputs "scan codes" when individual keys are pressed
and released.  These scan code values may be keyboard specific (i.e.
non-standardized, at least for some keys).

The kernel translates scan codes to a "kernel keycode".  (I don't know
exactly what it is called.)

I believe Xorg translates the kernel keycodes to Xorg keycodes.

Xorg will send KeyPress and KeyRelease events to Openbox.  Each event
contains the following integer values:  keycode, keysym, and state.
(Keysym represents the "meaning" of the key, and can be changed by
switching to a different keyboard layout, for example).  State is a
bit-mask that represents which of the modifier keys is also pressed.
The modifier keys are Control, Alt, Super (i.e. Windows), Meta, and
possibly other modifier keys.

The upshot is that Steve is probably effectively correct.  Because the
modifier keys are represented in each event by the "state" bit-mask,
it is quite possible that the "state" bit-mask represents the same
keyboard that the scan code originally came from.  (Unlike Steve, I
suspect this happens in the kernel or in Xorg, not in the keyboard
itself, but I could be wrong.)

And Openbox is probably looking at the state field of the event in
order to determine which modifier keys are pressed.

You should be able to examine the KeyPress and KeyRelease events,
including the state bit-mask, by using the xev program.

Have you considered buying a split keyboard?  I use an Ultimate
Hacking Keyboard, but there are lots of split keyboards options
available today.

Parke


More information about the openbox mailing list