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

Modifier keys should be valid hotkeys #27

Closed
adamcbrewer opened this issue May 21, 2018 · 3 comments
Closed

Modifier keys should be valid hotkeys #27

adamcbrewer opened this issue May 21, 2018 · 3 comments

Comments

@adamcbrewer
Copy link

Currently it's not possible to use the modifier keys (shift, command, alt, etc.) on their own.

hotkeys('shift+enter', () => {}); // works
// but...
hotkeys('shift', () => {}); // does not work
// similarly...
hotkeys('alt', () => {}); // does not work
hotkeys('cmd', () => {}); // does not work

Could this be added as a feature request or would you accept a pull-request with this functionality?

@jaywcjlove
Copy link
Owner

jaywcjlove commented May 21, 2018

@adamcbrewer I accept this pull-request.

@jaywcjlove
Copy link
Owner

jaywcjlove commented May 21, 2018

Support this form.

hotkeys('*', function(e){
  if(hotkeys.shift) console.log('shift is pressed!');
  if(hotkeys.ctrl) console.log('ctrl is pressed!');
  if(hotkeys.alt) console.log('alt is pressed!');
  if(hotkeys.option) console.log('option is pressed!');
  if(hotkeys.control) console.log('control is pressed!');
  if(hotkeys.cmd) console.log('cmd is pressed!');
  if(hotkeys.command) console.log('command is pressed!');
});

@adamcbrewer
Copy link
Author

The issue is I don't want to bind to every key to just check for a single modifier. I think I'll try and find a similar library that supports modifiers on their own before submitting a pull request. Thanks!

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

No branches or pull requests

2 participants