Py5KeyEvent.get_action()#

Return the key event’s action.

Examples#

 1def setup():
 2    py5.size(200, 200, py5.P2D)
 3    py5.rect_mode(py5.CENTER)
 4
 5
 6def draw():
 7    py5.square(py5.random(py5.width), py5.random(py5.height), 10)
 8
 9
10def key_pressed(e):
11    py5.println('key pressed:', e.get_action() == e.PRESS)
12
13
14def key_released(e):
15    py5.println('key released:', e.get_action() == e.RELEASE)
16
17
18def key_typed(e):
19    py5.println('key typed:', e.get_action() == e.TYPE)

Description#

Return the key event’s action. This value will always be implied by the triggered event function, but perhaps it might be useful to someone someday.

Underlying Processing method: getAction

Syntax#

get_action() -> int

Updated on April 27, 2022 10:44:51am UTC