pyunity.input module

class pyunity.input.KeyState[source]

Bases: enum.IntEnum

An enumeration.

UP = 1
DOWN = 2
PRESS = 3
NONE = 4
class pyunity.input.KeyCode[source]

Bases: enum.IntEnum

An enumeration.

A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
I = 9
J = 10
K = 11
L = 12
M = 13
N = 14
O = 15
P = 16
Q = 17
R = 18
S = 19
T = 20
U = 21
V = 22
W = 23
X = 24
Y = 25
Z = 26
Space = 27
Alpha0 = 28
Alpha1 = 29
Alpha2 = 30
Alpha3 = 31
Alpha4 = 32
Alpha5 = 33
Alpha6 = 34
Alpha7 = 35
Alpha8 = 36
Alpha9 = 37
F1 = 38
F2 = 39
F3 = 40
F4 = 41
F5 = 42
F6 = 43
F7 = 44
F8 = 45
F9 = 46
F10 = 47
F11 = 48
F12 = 49
Keypad0 = 50
Keypad1 = 51
Keypad2 = 52
Keypad3 = 53
Keypad4 = 54
Keypad5 = 55
Keypad6 = 56
Keypad7 = 57
Keypad8 = 58
Keypad9 = 59
Up = 60
Down = 61
Left = 62
Right = 63
class pyunity.input.MouseCode[source]

Bases: enum.IntEnum

An enumeration.

Left = 1
Middle = 2
Right = 3
class pyunity.input.KeyboardAxis(name, speed, positive, negative)[source]

Bases: object

get_value(dt)[source]
class pyunity.input.Input[source]

Bases: object

classmethod GetKey(keycode)[source]

Check if key is pressed at moment of function call

Parameters:keycode (KeyCode) – Key to query
Returns:If the key is pressed
Return type:boolean
classmethod GetKeyUp(keycode)[source]

Check if key was released this frame.

Parameters:keycode (KeyCode) – Key to query
Returns:If the key was released
Return type:boolean
classmethod GetKeyDown(keycode)[source]

Check if key was pressed down this frame.

Parameters:keycode (KeyCode) – Key to query
Returns:If the key was pressed down
Return type:boolean
classmethod GetKeyState(keycode, keystate)[source]

Check key state at moment of function call

Parameters:
  • keycode (KeyCode) – Key to query
  • keystate (KeyState) – Keystate, either KeyState.PRESS, KeyState.UP or KeyState.DOWN
Returns:

If the key state matches

Return type:

boolean

classmethod GetMouse(mousecode)[source]

Check if mouse button is pressed at moment of function call

Parameters:mousecode (MouseCode) – Mouse button to query
Returns:If the mouse button is pressed
Return type:boolean
classmethod GetMouseUp(mousecode)[source]

Check if mouse button was released this frame.

Parameters:mousecode (MouseCode) – Mouse button to query
Returns:If the mouse button was released
Return type:boolean
classmethod GetMouseDown(mousecode)[source]

Check if mouse button was pressed down this frame.

Parameters:mousecode (MouseCode) – Mouse button to query
Returns:If the mouse button was pressed down
Return type:boolean
classmethod GetMouseState(mousecode, mousestate)[source]

Check for mouse button state at moment of function call

Parameters:
  • mousecode (MouseCode) – Key to query
  • mousestate (KeyState) – Keystate, either KeyState.PRESS, KeyState.UP or KeyState.DOWN
Returns:

If the mouse button state matches

Return type:

boolean

classmethod GetAxis(axis)[source]

Get the value for the specified axis. This is always between -1 and 1.

Parameters:axis (str) – Specified axis
Returns:Axis value
Return type:float
Raises:PyUnityException – If the axis is not a valid axis
classmethod GetRawAxis(axis)[source]

Get the raw value for the specified axis. This is always either -1, 0 or 1.

Parameters:axis (str) – Specified axis
Returns:Raw axis value
Return type:float
Raises:PyUnityException – If the axis is not a valid axis
classmethod UpdateAxes(dt)[source]