- Home /
Prevent unity hotkeys in editor
I'm trying to create an editor script, but even when I do Event.current.Use()
in my script, it still fires hotkeys in the background. For example: if I hold the X key, even though I'm consuming the KeyDown
and KeyUp
events, the Global/Local button keeps toggling.
How can I prevent my keyboard events from passing through to the editor?
If you find an answer, please share.
$$anonymous$$y guess is that we can't bypass Unity Editor (and System, of course) hotkeys. I use to refer to this sheet when I have to set a new hotkey and avoid conflicts.
Be aware that if you want to implement Shift+letter keys, you will need to add some logic to avoid to accidently trigger the hotkey while editing some name/text.
$$anonymous$$outon: Even if we're focused on a different window?
If by different window you mean an EditorWindow, yes.
To prevent your hotkey to trigger when you are in a text field, you can check the value EditorGUIUtility.editingTextField.