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

shortcuts without modifier keys prevent writing that key in inputs #29

Closed
nfcampos opened this issue Feb 3, 2016 · 5 comments
Closed

Comments

@nfcampos
Copy link
Contributor

nfcampos commented Feb 3, 2016

<DockMonitor toggleVisibilityKey='s'>
  <LogMonitor/>
</DockMonitor>

Hi,

setting a shortcut like that (without a modifier key) prevents me from typing that letter in inputs (because handleKeyDown() calls event.preventDefault())

one solution for this would be to add this line
if (e.target !== document.body) return
to handleKeyDown() because if an input is focused the target of the keydown event is that input, if no input is focused the target of the event is the body

another solution would be to return if the tag name of the target of the event is input, textarea, etc.

would you be open to doing one of these things, or some other way of not triggering the shortcuts while an input is focused?

Thanks,
Nuno

(also, thanks a lot for all you've done with redux,etc it plays a big part in how i write apps now 😃 )

@gaearon
Copy link
Owner

gaearon commented Feb 3, 2016

Thanks for kind words.
Why not just set a shortcut with modifier key?

@nfcampos
Copy link
Contributor Author

nfcampos commented Feb 3, 2016

that was just because this app i'm working on has other shortcuts like that (without modifier key) and it was just to be consistent. (the shortcut library https://craig.is/killing/mice i use for the other shortcuts does this thing of not triggering them when focused on an input)

@gaearon
Copy link
Owner

gaearon commented Feb 3, 2016

I'm happy to add a check like this. Want to send a PR?

@nfcampos
Copy link
Contributor Author

nfcampos commented Feb 3, 2016

done :)

@gaearon
Copy link
Owner

gaearon commented Feb 19, 2016

Fixed by #30.

@gaearon gaearon closed this as completed Feb 19, 2016
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