Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

pyunity.input module


class pyunity.input.KeyState[source]

Bases: IntEnum

An enumeration.

UP = 1

Type:    int

DOWN = 2

Type:    int

PRESS = 3

Type:    int

NONE = 4

Type:    int

class pyunity.input.KeyCode[source]

Bases: IntEnum

An enumeration.

A = 1

Type:    int

B = 2

Type:    int

C = 3

Type:    int

D = 4

Type:    int

E = 5

Type:    int

F = 6

Type:    int

G = 7

Type:    int

H = 8

Type:    int

I = 9

Type:    int

J = 10

Type:    int

K = 11

Type:    int

L = 12

Type:    int

M = 13

Type:    int

N = 14

Type:    int

O = 15

Type:    int

P = 16

Type:    int

Q = 17

Type:    int

R = 18

Type:    int

S = 19

Type:    int

T = 20

Type:    int

U = 21

Type:    int

V = 22

Type:    int

W = 23

Type:    int

X = 24

Type:    int

Y = 25

Type:    int

Z = 26

Type:    int

Space = 27

Type:    int

Alpha0 = 28

Type:    int

Alpha1 = 29

Type:    int

Alpha2 = 30

Type:    int

Alpha3 = 31

Type:    int

Alpha4 = 32

Type:    int

Alpha5 = 33

Type:    int

Alpha6 = 34

Type:    int

Alpha7 = 35

Type:    int

Alpha8 = 36

Type:    int

Alpha9 = 37

Type:    int

F1 = 38

Type:    int

F2 = 39

Type:    int

F3 = 40

Type:    int

F4 = 41

Type:    int

F5 = 42

Type:    int

F6 = 43

Type:    int

F7 = 44

Type:    int

F8 = 45

Type:    int

F9 = 46

Type:    int

F10 = 47

Type:    int

F11 = 48

Type:    int

F12 = 49

Type:    int

Keypad0 = 50

Type:    int

Keypad1 = 51

Type:    int

Keypad2 = 52

Type:    int

Keypad3 = 53

Type:    int

Keypad4 = 54

Type:    int

Keypad5 = 55

Type:    int

Keypad6 = 56

Type:    int

Keypad7 = 57

Type:    int

Keypad8 = 58

Type:    int

Keypad9 = 59

Type:    int

Up = 60

Type:    int

Down = 61

Type:    int

Left = 62

Type:    int

Right = 63

Type:    int

class pyunity.input.MouseCode[source]

Bases: IntEnum

An enumeration.

Left = 1

Type:    int

Middle = 2

Type:    int

Right = 3

Type:    int

class pyunity.input.KeyboardAxis[source]

Bases: object

getValue(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

mousePosition = None

Type:    None

classmethod UpdateAxes(dt)[source]