Open aarongustafson opened 5 years ago
I think this discussion pairs well with the open question on reserved keys.
How do we handle reserved or overwritten kbd shortcuts from the OS?
So rather than start a new thread, I think it would be good to discuss the idea of colliding keys in whole, regardless of if they are A11y software, OS, or something else that is trying to register a key on top of your PWA.
Electron has an API for asking if a key is registered, it is called globalShortcut.isRegistered. This returns a boolean as to whether the shortcut is known already to the OS or not.
Building on this kind of an idea, we should not make key combos fully declarative. A developer may, as @aarongustafson points out, want to allow key remapping to suit a style the user is more comfortable with. The declarations would be a good baseline, but to get deeper control we need an imperative API.
The declarative API could do a "best attempt" registration. Try to register, but if you can't give the developer some way to notice it wasn't possible. Console error (seems odd though since you can't really catch this), maybe some object associated with the imperative API can store errors from this.
An imperative API would allow a developer to:
Two questions regardless though if we agreed o this kind of approach:
Assuming yes, we’d likely need a mechanism to remap the keys.
Also: Would that require some means of accessing the new mapping information via JavaScript? I could see that being important for any in-app documentation (allowing for the shortcut keys to be dynamically assigned or updated in the prose).