Mac: 'option+n' don't trigger callback
See original GitHub issueWe 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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Hi @SO-Eng thx for raising that issue. I’ll check that out and come back to you 😃
Fixed in 4.1.0