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.

Mac: 'option+n' don't trigger callback

See original GitHub issue

We have a WebApp, where we implemented ‘alt+n’ to open a form. This also triggers, when user focuses an input field and press ‘alt+n’. Means, current form will be saved and a new one will be opened. Everything work’s as expected!

Now we refactor all our hotkey events for Mac users and we struggle at ‘option+n’. It work’e well, when no form is open. Also when the form is open, but no input field is focused. But when an input field is focused (and that should be the most case in a form), ‘option+n’ writes a tilde ‘~’ and nothing happens.

We also have ‘alt+t, option+t’ to open a modal with templates to fill the form. This also work’s well with alt and option as modifier.

Only ‘option+n’ doesn’t. Any idea why? What I recognized in this sample code from your documentation page now, that ‘option+n’ counts 2 up when not focusing the input field, but ‘alt+n’ or ‘option+t’ counts 1 as it should. Seems to be that underline below tilde what is shown but does not remain.

function ExampleComponent() {
  const [count, setCount] = useState(0)

  useHotkeys(
   'alt+n, option+t, option+n', 
   (e) => {
     e.preventDefault;
     setCount(prevCount => prevCount + 1);
   },
   {
     enableOnTags: ["INPUT", "TEXTAREA"],
   }
  );

  return (
  <div>
    <span>Received the combination {count} times.</span>
    <input />
  </div>
  )
}

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
JohannesKlausscommented, Jan 19, 2022

Hi @SO-Eng thx for raising that issue. I’ll check that out and come back to you 😃

0reactions
JohannesKlausscommented, Dec 25, 2022

Fixed in 4.1.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

IOHIDManager not triggering callback for keyboard
Currently, I am creating an OpenGL context and starting it fullscreen. I am trying to now add keyboard input so I can quit...
Read more >
Use x-callback-url with Shortcuts on Mac - Apple Support
Shortcuts supports x-callback-url, allowing the calling app to receive a response (a callback) when a particular interaction has completed.
Read more >
JohannesKlauss/react-hotkeys-hook - GitHub
React hook for using keyboard shortcuts in components. ... If you set both keyup and keydown to true, the callback will trigger on...
Read more >
Process | Node.js v19.3.0 Documentation
Normally, the Node.js process will exit when there is no work scheduled, but a listener registered on the 'beforeExit' event can make asynchronous...
Read more >
chrome.commands - Chrome Developers
Beginning in Chrome 35, extension developers can optionally mark a command as "global". Global commands also work while Chrome does not have focus....
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