Skip to content

Unify key decoding for keydown #1676

Closed
Closed
@mrmr1993

Description

@mrmr1993

At the moment, we decode keys seperately for each keydown handler. With a view to reducing bugs and handling international keyboard layouts correctly, I think we should centralise conversion from event to the key we want to handle.

Pros:

  • duplicated/similar code is moved to a library function.
  • we will have to make anomalies in keydown handling explicit, which will help with debugging
  • when (or before) Chromium issue 227231 is resolved, we have a centralised place to implement on the new feature. From this point, we can stop relying on the depreciated keypress event, by using event.key when it's available:
    • this will solve all keyboard internationalisation issues immediately (passing keys we are going to handle, and blocking the events for those we aren't)
    • we can't be pre-empted by keydown handlers for keys we want to handle, where event.keyCode disagrees with what we get from a keypress event (eg. a page handles a, but we handle an internationalised key that represents as a during keydown)
    • we move to a single key handler, since our keypress handlers will never get events for any key we handle
  • friendlier key-handling code

Cons:

  • code movement/refactoring
  • bugs from missed edge cases due to platfrom inconsistency
  • no visible benefit for the user
    • the Chromium issue will change this but will also require extra work
  • redundancy in the code until old Chrome versions are abandoned (for event.key considerations only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions