- Home /
Listen to Keyboard Events on EditorWindow
Hi guys, how I can get currently pressed keyboard while I'm in EditorWindow
?
Here's my latest code (but didn't work, Event.current
is always null) :
void Update(){
if(Event.current!=null && Event.current.isKey && con.Listen ())
Repaint ();
}
public bool Listen(){
switch(Event.current.keyCode){
case KeyCode.DownArrow:
// ...
break;
case KeyCode.UpArrow:
// ...
break;
default:
break;
}
return c;
}
Answer by WillNode · May 21, 2015 at 08:13 PM
sorry, I never know that it will works while I'm inside OnGUI
void OnGUI(){
if(Event.current!=null && Event.current.isKey && con.Listen ())
Repaint ();
}
Never$$anonymous$$d, I found another way to make it work: https://answers.unity.com/questions/130898/how-to-check-if-a-key-is-down-in-editor-script.html
If anybody needs it
Your answer
Follow this Question
Related Questions
Detect Enter Key Event with GUILayout.TextField Focused 1 Answer
Detecting moment when GameObiect is created in hierarchy. 1 Answer
How to open an Editor Window by using the MethodInfo.Invoke function ? 1 Answer
How to switch back the Hierarchy window to scene from prefab? 0 Answers
How can an editor script know when another script was removed from the project? 1 Answer