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.

Can't detect shift alone

See original GitHub issue

Shift by itself doesn’t work.

hotkeys('shift', function() {
  console.log('Shift pressed')
})

Here’s a working example: CodeSandbox

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ashconnellcommented, Jul 2, 2020

@jaywcjlove how would I differentiate between shift and shift+command+z then? I don’t want the shift behaviour to happen when they actually pressed other keys with it

1reaction
jaywcjlovecommented, Jul 2, 2020

@ashconnell Modifier keys cannot be set.

hotkeys("*", function(event, handler) {
  console.log("event", event);
  console.log("handler", handler);
  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!");
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Shift Key Not Working [SOLVED] - Driver Easy
4) Press the Shift key on your keyboard to see if it work. If your Shift key keeps not functioning, try to update...
Read more >
some keyboard keys not working with shift key.
Press Windows key + I to open Settings. Select Time & Language. Under Region & language, you can check whether the Country or...
Read more >
Detect Shift key is pressed without using events in Windows ...
If you want to check whether Shift alone is pressed without any other modifiers, use if (Control.ModifierKeys == Keys.Shift).
Read more >
Solved: some keys in my keyboard don't work while holding shift.
Solved: Hi, 3 days ago I noticed that I can't jump while sprinting in games (sprint: Shift --- jump: Space). at first i...
Read more >
Solved! - Keyboard key not working without pressing shift
If this doesn't work, you may wish to try connecting/reconnecting an external keyboard and see if it works fine.
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