Py5KeyEvent.get_native()#

Retrieve native key event object.

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    native_event = e.get_native()
12    if native_event != None:
13        py5.println(native_event.getKeyChar())

Description#

Retrieve native key event object. The returned object will be a Java object and its type can vary based on the renderer used by the Sketch and the operating system the Sketch is run on. Sometimes the native object can be used to access functionality not otherwise available through Processing or py5.

Be aware that it is possible for the native event object to be None, such as when interacting with a Sketch through py5_tools.sketch_portal().

Underlying Processing method: getNative

Syntax#

get_native() -> Any

Updated on May 17, 2022 15:08:25pm UTC