KeyboardEvent.key, KeyboardEvent.which



Chromium reports wrong values after keyboard layout change

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36

Steps to reproduce the problem:

  1. Initial settings — two keyboard layouts switched by Caps Lock, swapped Ctrl and Alt:
    $ cat .xinitrc 
    setxkbmap dvorak,ru -option grp:caps_toggle
    xmodmap .Xmodmap
    $ cat .Xmodmap 
    clear control
    clear mod1
    keycode 37 = Alt_L Meta_L
    keycode 105 = Alt_R Meta_R
    keycode 64 = Control_L
    keycode 108 = Control_R
    add control = Control_L Control_R
    add mod1 = Alt_L Meta_L
  2. Change settings to QWERTY:
    $ setxkbmap us
  3. Try input above.

What is the expected behavior?

KeyboardEvent.key and KeyboardEvent.which should match my input.

What went wrong?

I type QWERTY but key and which shows Dvorak values. I press Ctrl, it displays Alt, but setxkbmap resets xmodmap.

Other browsers tested:

Firefox 83.0: OK

Bug tracking.