question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modifier keys combined with normal keys

See original GitHub issue

Hey @lukeraymonddowning

I am looking for key handler library and this one seems to be very promising 😃

Maybe it’s not supported or I am doing something wrong but this is not working (same for Shift):

whenipress("Alt", "s")
  .then(() => console.log("press alt+s"))
  .whenReleased(() => console.log("release alt+s"));

It’s only triggered once or not at all and the release hook is never triggered. I am using a Macbook Pro.

codesandbox: https://codesandbox.io/s/focused-forest-vdg1l?file=/src/index.js

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeraymonddowningcommented, Mar 28, 2021

Actually @moklick further to this, ignore my previous comment.

It doesn’t work because alt modifies the S key. You can use the key code instead:

whenipress("Alt", "KeyS")
  .then(() => console.log("press alt+s"))
  .whenReleased(() => console.log("release alt+s"));

This site is super useful for this kind of stuff: https://keycode.info

0reactions
moklickcommented, Mar 28, 2021

Thanks! I wasn’t aware that it’s possible to pass the code as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifier key - Wikipedia
In computing, a modifier key is a special key (or combination) on a computer keyboard that temporarily modifies the normal action of another...
Read more >
Change the behavior of the modifier keys on Mac
Change the behavior of the modifier keys on Mac · On your Mac, choose Apple menu > System Settings, then click Keyboard in...
Read more >
Your PC Keyboard's Modifier Keys - Dummies.com
Four keys on your keyboard are modifier keys. A modifier key works in combination with other keys to do various interesting and unbelievable ......
Read more >
Use normal keys as modifier keys, e.g. press S and F together ...
Base keys are all keyboard keys except modifier keys. Luckily there is a trick. ... If yes, we send our new key combination...
Read more >
Modifier Keys - the Tcler's Wiki!
A binding with Modifier Alt is overridden by a binding with Modifier Option, Mod2, or M2. When the Modifier key is pressed, two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found