Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need algorithm for how events are fired for key presses #142

Open
garykac opened this issue May 16, 2017 · 3 comments
Open

Need algorithm for how events are fired for key presses #142

garykac opened this issue May 16, 2017 · 3 comments

Comments

@garykac
Copy link
Member

garykac commented May 16, 2017

Since it's more complicated than simply:

  • keydown
  • beforeinput
  • keypress (deprecated)
  • input
  • keyup

For example, see whatwg/html#2605 which talks about inconsistencies in how UAs treat key presses in controllers.

Also cover how key events are handled during composition.

Starting proposal (needs to be verified):

global_state: inComposition = False

  • if target is a controller, then
    • return
  • send keydown event
  • if keydown is not cancelled, then
    • if key triggers composition, then
      • set inComposition = True
      • send compositionstart event
      • if compositionstart event is cancelled, then
        • ...
      • send compositionupdate event
    • else if inComposition and key triggers exiting composition, then
      • send compositionend event
      • set inComposition = False
    • else
      • send beforeinput
      • if beforeinput event is not cancelled, then:
        • if inComposition, then
          • send compositionupdate event
        • Update the DOM
        • send input event
  • send keyup
@domenic
Copy link

domenic commented Apr 10, 2018

It seems like we'd need some kind of loop in there to handle the case where I hold down a key and don't let it go until several characters have been entered. That should trigger at least a few input events, I'd think?

@domenic
Copy link

domenic commented Apr 10, 2018

Regarding integration with the input/composition events, my instinct would be to start with one big all-together algorithm then try to refactor if possible.

@garykac
Copy link
Member Author

garykac commented Jul 31, 2020

Draft proposal for an algorithm to specify how keyboard, input and composition events are fired:

https://docs.google.com/document/d/1LJQvjEmWZGzVgZnofpvdkxMj1hEnLniD72XD4DLJWx4/edit?usp=sharing

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

No branches or pull requests

2 participants