-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[lib.dom.d.ts] Include well-known KeyboardEvent.key values #38886
Comments
Unfortunately as soon as you have readonly key: string | ModifierKeys | WhitespaceKeys ...
As for suggestions see #29729 |
We could go the route of ‘csstypes’ and have it be an external package that augments the current type definitions, though I’m not sure it will work if the type is already the wider |
huh. I knew that I was under the impression that the autocomplete would continue to work, and didn't realize that |
I'm open @ferdaber's suggestion of making an external definition, like |
I think this is blocked on #29729 getting solved but could proceed after that |
The IntelliSense will help prevent many scenarios. I created a small external package that contains the types of the KeyboardEvent.key while the current-suggestion is blocked. |
Search Terms
keyCode
KeyboardEvent
KeyboardEvent.key
KeyboardEvent.keyCode
Suggestion
Include
KeyboardEvent.key
values in theKeyboardEvent
interface.The current implementation is:
See here for a list of some possible values.
Here is my suggestion for how this type can be usefully updated:
In the above I left out
EditingKeys
,UIKeys
,DeviceKeys
,IMEKeys
,PhoneKeys
,MultimediaKeys
,AudioControlKeys
,TVControlKeys
,MediaControllerKeys
,SpeechRecognitionKeys
,DocumentKeys
,ApplicationSelectorKeys
, andBrowserControlKeys
, but we could either include them all at the start or just as necessary.Use Cases
When a user is accessing the
KeyboardEvent.key
API, a sane set of the known defaults should be available for type checking.Examples
This will help prevent scenarios like:
Since users will get completion on common values when typing.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: