- Home /
This question was
closed Jul 01, 2015 at 06:34 PM by
meat5000 for the following reason:
The question is answered, right answer was accepted
How to determine if a keyboard key or a mouse key was pressed?
Input.anyKey return true if a keyboard or mouse button was pressed. How can I tell if only a keyboard button was pressed?
Comment
Best Answer
Answer by meat5000 · Jul 01, 2015 at 11:07 AM
The example in the documentation
function OnGUI() {
var e : Event = Event.current;
if (e.isKey) {
Debug.Log("Detected key code: " + e.keyCode);
}
}
Will detect keyboard but not mouse. I just tried it.
Answer by SuperMasterBlasterLaser · Jul 01, 2015 at 11:01 AM
Jus use && in your if sentence:
if (Input.anyKey && Input.GetKeyUp(Your_Key_Code)) {
}
if (Input.anyKey && Input.GetKey(KeyCode.Mouse0)) {
}
Follow this Question
Related Questions
Multiple Players on one Computer/Console 5 Answers
Knowing when mouse has been released 2 Answers
Mouse Hold Down 2 Answers
How can I change mouse clicks to keyboard in order to enable a capsule collider? 0 Answers
movement control with keyboard & mouse 2 Answers