Skip to content

Keymap based on .key or .code rather than .keyCode? #74

Open
@jasongrout

Description

@jasongrout

Early in Phosphor/Lumino's development, we decided to use .keyCode instead of .key for the basis of the keyboard shortcut system. This came about in part because (among other things) we realized that browsers were inconsistent with the .key attribute when modifiers were used. For example (and I just checked this is still the case with Firefox 76), in Firefox we saw that on a mac, pressing the numbers on a en-us keyboard layout while holding shift, control, alt, and command, led to the following sequence of event.key attributes:

1@345^7890

On Chrome, we get:

1€345fl7890

I suppose once browsers can be consistent about .key, we can look again at a keyboard shortcut system that depends on it. A nice thing about using .key is that presumably it would transparently support different keyboard maps, instead of relying on manually creating and selecting keyboard maps.

Another option, as @vidartf points out below, is moving to the .code attribute, especially since .keyCode is both deprecated and a bit convoluted across different browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions