Event.KEY DOWN

From GiderosMobile
Revision as of 00:00, 1 August 2025 by MoKaLux (talk | contribs)

Available since: Gideros 2011.6
Value: keyDown
Defined by: Sprite

Description

This event is dispatched when a supported key is pressed. List of supported keys KeyCode Constants.

Parameters

type: (String) keyDown
keyCode: (number) code of the key pressed
realCode: (number) real keyCode underneath
modifiers: (number) modifiers present:
   no key modifier, KeyCode.MODIFIER_NONE, 0
   SHIFT key modifier, KeyCode.MODIFIER_SHIFT, 1
   LEFT ALT modifier, KeyCode.MODIFIER_ALT, 2
   CONTROL modifier, KeyCode.MODIFIER_CTRL, 4
   RIGHT ALT modifier, KeyCode.MODIFIER_ALT, 6
   META modifier, KeyCode.MODIFIER_META, 8

Example

function onKeyDown(e)
	print(e.keyCode, e.realCode, e.modifiers)
end
stage:addEventListener(Event.KEY_DOWN, onKeyDown)

note: for this event to work you need to add your sprite to the stage (scene)

See also

Event.KEY UP
Event.KEY CHAR