Issue with calling runScopeHandlers with ctrl+shift

I have created a search panel with an input. I feed the keyboard events from that input into the CodeMirror view with runScopeHandlers.

I have key bindings:

  • Mod+Shift+h for replaceAll
  • Mod+h for replaceNext

While my search panel input has focus, Mod+Shift+h will call replaceAll just fine. But when I have cap locks on, then Mod+Shift+h will instead call replaceNext. The difference between the two keyboard events is if cap locks is on then key=’h’ instead of ‘H’.

The issue happens in keymap.ts runHandlers line 250…

      if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {

This is the first runFor check that’s called. The third argument for modifiers says that shift is always false. So when cap locks in ON it’ll return “Ctrl+h” which matches replaceNext exactly and calls that one (which we don’t want). When cap locks is OFF it’ll return “Ctrl+H” which doesn’t match anything, then it’ll fall through and call a runFor that allows the shift modifier.

Not sure what the best fix is here…

Which platform are you on? On Linux, Ctrl-h seems to still produce an event with key equal to "h", even with Caps Lock on, and I’m seeing the expected key bindings fire.

I’m on Windows 11 + Chrome

I tested on Firefox too and caplocks will make the key uppercase. Caplocks + shift will make the key lowercase again.

I tested it not in my app, but just adding this in dev tools:
document.addEventListener(‘keydown’, (e) => console.log(e))

Actually, I’m seeing the problem because the first runFor ignores the shift modifier because of “!isChar”. So even if I presss Ctrl-Shift-h, it looks up the keybinding for Ctrl-h first and finds the wrong command. It just so happens that when caplocks is off it “fixed” the problem because it was trying to look up the keybinding for Ctrl-H and failing to match.