w3c / uievents

UI Events
https://w3c.github.io/uievents/
Other
145 stars 51 forks source link

Redefine when `keypress` event should be fired #266

Open masayuki-nakano opened 4 years ago

masayuki-nakano commented 4 years ago

Currently, keypress event is defined as that it's fired only when a key press introduces a character.

https://w3c.github.io/uievents/#event-type-keypress

If supported by a user agent, this event MUST be dispatched when a key is pressed down, if and only if that key normally produces a character value

However, both Chrome and Safari violates this rule, but some web apps may depend on control character inputting keypress. So, there should be clearer and not breaking existing web apps rule.

masayuki-nakano commented 4 years ago

@garykac According to the behavior of Chrome for Windows, Chrome exposes only some control character inputs even when a printable key with Ctrl key is pressed. But I don't find the code nor the reason yet. Do you know somebody who know around it?

garykac commented 4 years ago

Today's a holiday, but I'll follow up on this tomorrow. I know how to track down more info about this.

garykac commented 4 years ago

I was unsuccessful tracking down more info on this. But I can try reaching out more broadly.

It feels like this should be generating an input event rather than a keypress event. Since keypress is deprecated, we can't ask people to rely on it.

zcorpan commented 6 months ago

It feels like this should be generating an input event rather than a keypress event. Since keypress is deprecated, we can't ask people to rely on it.

I strongly disagree on this point. IMO, the spec should require what browsers need to implement in order to make web pages work as intended. @masayuki-nakano cited a web compat requirement. If the spec requires something different from what browsers need to implement to be compatible with the web, then the spec will be ignored.

I think this is a fundamental principle for web specs.

Things can be marked as deprecated or obsolete and still have non-optional, well-defined and web-compatible specification.