Skip to Content
Mastering UI Development with Unity
book

Mastering UI Development with Unity

by Dr. Ashley Godbold
April 2018
Beginner content levelBeginner
468 pages
11h 7m
English
Packt Publishing
Content preview from Mastering UI Development with Unity

GetKey

If you want to get a keyboard key press that is not assigned to an axis, you can use GetKey(), GetKeyDown(), or GetKeyUp() to reference keyboard keys via their KeyCode.

The GetKey() functions work pretty similar to the GetButton() functions. GetKey() returns true while the key is being held down; GetKeyDown() returns true only once, on the frame that the key is initially pressed; and GetKeyUp() returns true only once, on the frame that the key is released.

Each key has its own KeyCode that needs to be referenced in the parentheses of the GetKey() functions. You can find a list of all the keyboard KeyCodes at https://docs.unity3d.com/ScriptReference/KeyCode.html.

So, for example, if you wanted to check whether the 8 key from the alphanumeric ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Game Development with Unity for .NET Developers

Game Development with Unity for .NET Developers

Jiadong Chen
Unity UI Cookbook

Unity UI Cookbook

Francesco Sapio

Publisher Resources

ISBN: 9781787125520Supplemental Content