Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Shift keyevent interrupts matching a key sequence #65

Closed
flannelhead opened this issue Jan 8, 2015 · 4 comments · Fixed by #67
Closed

Shift keyevent interrupts matching a key sequence #65

flannelhead opened this issue Jan 8, 2015 · 4 comments · Fixed by #67

Comments

@flannelhead
Copy link

Investigating a vim-mode bug about bindings like 'i (' and 'i {' being ignored, I found the following: pressing shift alone generates a keydown event. Thus, when typing a sequence like 'i (', the 'i' gives a partial match. Then, on my keyboard, typing '(' involves pressing shift and 9 simultaneously. The shift key alone, however, generates a separate keydown event before the 9 keypress, so the partial matching gets interrupted before the actual '(' keydown event comes in. I verified this by console.logging the keydown events received on Chromium 39, Linux.

EDIT: this can be also verified by having vim-mode on, looking at the keybinding resolver. In command mode, press first 'c', then 'i'. There's the list of partial matches. As soon as I push down the shift key to type '(', the list of partial matches disappears before I could type in the actual '('.

EDIT 2: This might be Linux specific.

@flannelhead flannelhead changed the title Shift keyevent interrupts matching key sequence Shift keyevent interrupts matching a key sequence Jan 8, 2015
@mdaffin
Copy link

mdaffin commented Jan 9, 2015

I am seeing the same thing in archlinux with the UK keyboard layout

@flannelhead
Copy link
Author

Okay, now I've checked this on Windows 8.1. There seems to be no problem. Furthermore, I've narrowed down the issue.

atom-keymap detects if the event was caused by a modifier key using a set of keyIdentifiers for those modifier keys. It however happens that at least for me on Linux (checked US-qwerty, US-colemak and FI-qwerty layouts), the keyIdentifier for the ctrl key isn't Ctrl but U+00A2. Similarly, the identifier for the shift key is U+00A0 and for alt it's U+00A4. This was checked by executing

window.addEventListener('keydown', function(e) { console.log(e); });

in the Chromium console, pressing the keys ctrl, shift and alt one at a time, and looking at the log output.

It would be a trivial fix to add these identifiers to KeyboardEventModifiers, but I don't know if it would have any side effects on other platforms.

On Windows these identifiers seemed to be as they should: Ctrl, Shift and Alt.

@nathansobo
Copy link
Contributor

I don't think it should cause issues on other platforms because we only check that set for determining if the key is a modifier, and on other platforms it shouldn't be those identifiers. That said, this whole area is a minefield of unintended consequences.

@flannelhead
Copy link
Author

It should be noted, though, that U+00A0 is the code point for non-breaking space. Similarly, U+00A2 is the cent sign and U+00A4 is the currency sign. I wonder if it would cause any problems if those characters were regarded as modifiers. It's hard to imagine anybody using them in keybindings, though. Still, it is incredibly strange of Chromium to give those identifiers for ctrl, shift and alt.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants