Skip to content

Keydown event emits twice for printable char with one physical keypress #20726

Closed

Description

@kwonoj

i.e typing a produces below keyboard events:

image

while on chromium / ff emits single keydown event:

image

image

Behavior is related to #20630, currently each physical keypress creates two WindowEvent::KeyEvent for printable key, one without actual char and one subsequent with actual char. (window::handle_received_character).

This makes fixes around some keyboard event makes quite complex including previous PR #20327. (or #20630) - for example it is not easily create keypress event against U+000D for enter instead of \r which appends actual carriage return char in input field, etcs.

Peeking logics roughly, looks like it may possible

  • simply forward row winit kbdEvent without creating subsequent event for keychar
  • docuement owns the responsibility to map keycode to actual keychar, manage keypress event after emitting single keydown event

But can't say for sure around historical decisions for current codebases. I'm interested to try some changes if this is sound / feasible considerations.

Activity

  1. added
    A-content/dom
    on May 1, 2018
  2. kwonoj commented on May 2, 2018

    @kwonoj
    ContributorAuthor

    Related upstream issue: rust-windowing/winit#34

  3. paulrouget commented on May 3, 2018

    @paulrouget
    Contributor

    It would help to have a "Glutin Key To Servo Key" module as described in #20331 - at least to isolate the translation mechanism and properly define what we want in Servo.

  4. kwonoj commented on May 3, 2018

    @kwonoj
    ContributorAuthor

    Interesting. I'll followup how does #20331 proceeds and trying to figure out what's needed more. What I thought in here was slightly opposite, let document owns responsibility to create domkey from raw keyboardinput event, but that was speculative guess without any actual experiment.

  5. paulrouget commented on May 3, 2018

    @paulrouget
    Contributor

    And like I said in #20727, having proper IME support would help solve these kind of issues.

  6. kwonoj commented on May 8, 2018

    @kwonoj
    ContributorAuthor

    I'm bit unsure handling IME would resolve this issue (at least on win32, based on rough experiences) but still having proper IME support definitely related with these kind issues in any way. I realized it may need upstream winit side support, trying to make upstream changes first.

  7. atouchet commented on Apr 18, 2020

    @atouchet
    Contributor

    I tried retesting this with https://w3c.github.io/uievents/tools/key-event-viewer.html and now only get one keydown event.

    Screenshot

    Is this fixed now?

  8. jdm commented on Apr 20, 2020

    @jdm
    Member

    Looks like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domA-input

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions