Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Log an error if a keyboard shortcut uses keys not in the current keymap #374

Open
jasongrout opened this issue Feb 26, 2019 · 0 comments
Open

Comments

@jasongrout
Copy link
Member

Currently a user is not warned if they are using keys not in the current keymap. It would be helpful if an error is logged to the console (if not thrown outright) if a commands keybinding is registered that uses keys not in the keyboard layout.

I think it might be enough to check in https://github.com/phosphorjs/phosphor/blob/master/packages/commands/src/index.ts#L1028, or perhaps in

function createKeyBinding(options: CommandRegistry.IKeyBindingOptions): CommandRegistry.IKeyBinding {
if each key is a valid key in the keyboard layout using the getKeyboardLayout().isValidKey() function:
/**
* Test whether the given key is a valid value for the layout.
*
* @param key - The user provided key to test for validity.
*
* @returns `true` if the key is valid, `false` otherwise.
*/
isValidKey(key: string): boolean;

We had this come up in jupyterlab/jupyterlab#6027, where the user used "Up" instead of "ArrowUp". It would have been useful if there was an error in the console about an unrecognized key.

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

No branches or pull requests

2 participants