Class KeyCodeUtils
A collection of UnityEngine.KeyCode related utility methods.
public static class KeyCodeUtils
- Inheritance
-
KeyCodeUtils
- Inherited Members
Methods
GetAnalogValueForKey(string)
Gets the analog value for a key by string value, following the same logic as
GameInput.GetAnalogValueForButton(GameInput.Button)
public static float GetAnalogValueForKey(string s)
Parameters
sstring
Returns
- float
- 1f while a key is being held, otherwise 0f
- See Also
GetAnalogValueForKey(KeyCode)
Gets the analog value for a UnityEngine.KeyCode following the same logic as
GameInput.GetAnalogValueForButton(GameInput.Button)
public static float GetAnalogValueForKey(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
- float
- 1f while a key is being held, otherwise 0f
- See Also
-
KeyCode
GetKeyDown(string)
Check this is the first frame a key has been pressed.
public static bool GetKeyDown(string s)
Parameters
sstring
Returns
- bool
- True during the first frame a key has been pressed, otherwise false
- See Also
GetKeyDown(KeyCode)
Check this is the first frame a key has been pressed
public static bool GetKeyDown(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
- bool
- True during the first frame a key has been pressed, otherwise false
- See Also
-
KeyCode
GetKeyHeld(string)
Check a key is currently held down
public static bool GetKeyHeld(string s)
Parameters
sstring
Returns
- bool
- True every frame a key is held down, otherwise false
- See Also
GetKeyHeld(KeyCode)
Check a key is currently held down
public static bool GetKeyHeld(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
- bool
- True every frame a key is held down, otherwise false
- See Also
-
KeyCode
GetKeyHeldTime(string)
Check how long a key has been held down
public static float GetKeyHeldTime(string s)
Parameters
sstring
Returns
- See Also
GetKeyHeldTime(KeyCode)
Check how long a key has been held down
public static float GetKeyHeldTime(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
- See Also
-
KeyCode
GetKeyUp(string)
Check this is the first frame a key has been released
public static bool GetKeyUp(string s)
Parameters
sstring
Returns
- bool
- True during the first frame a key has been released, otherwise false
- See Also
GetKeyUp(KeyCode)
Check this is the frame a key has been released
public static bool GetKeyUp(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
- bool
- True during the first frame a key has been released, otherwise false
- See Also
-
KeyCode
KeyCodeToString(KeyCode)
Turn a UnityEngine.KeyCode into a string
public static string KeyCodeToString(this KeyCode keyCode)
Parameters
keyCodeKeyCode
Returns
StringToKeyCode(string)
Turn a string into a UnityEngine.KeyCode
public static KeyCode StringToKeyCode(string s)
Parameters
sstring
Returns
- KeyCode