Difference between revisions of "Event.KEY DOWN"

From GiderosMobile
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Value</translate>:''' keyDown<br/>
+
'''Value:''' keyDown<br/>
=== <translate>Descriptio</translate>n ===
+
'''Defined by:''' [[Sprite]]<br/>
<translate>Button on controller was pushed down</translate>
+
 
=== <translate>Parameters</translate> ===
+
=== Description ===
'''playerId''': (number) <translate>id of controller/player that pressed the button</translate><br/>
+
This event is dispatched when a supported key is pressed. For the list of supported keys, check the '''[[KeyCode]]''' class. Modifiers can have values of:
'''keyCode''': (number) <translate>button key code that was pressed</translate><br/>
+
*[[KeyCode.MODIFIER_NONE]]
__NOTOC__
+
*[[KeyCode.MODIFIER_SHIFT]]
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
*[[KeyCode.MODIFIER_CTRL]]  
'''<translate>Value</translate>:''' keyDown<br/>
+
*[[KeyCode.MODIFIER_ALT]]
=== <translate>Descriptio</translate>n ===
+
*[[KeyCode.MODIFIER_META]]
<translate>This event is dispatched when a supported key is pressed. For the list of supported keys, check [[Special:MyLanguage/KeyCode|KeyCode]] class.</translate>
+
 
=== <translate>Parameters</translate> ===
+
=== Parameters ===
'''keyCode''': (number) <translate>code of the key pressed.</translate><br/>
+
'''keyCode''': (number) code of the key pressed<br/>
'''realCode''': (number) <translate>real keyCode underneath</translate><br/>
+
'''realCode''': (number) real keyCode underneath<br/>
 +
'''modifiers''': (number) modifiers present, or nil if not supported<br/>
 +
 
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
function onKeyDown(e)
 +
print(e.keyCode, e.realCode, e.modifiers)
 +
end
 +
 
 +
stage:addEventListener(Event.KEY_DOWN, onKeyDown)
 +
</syntaxhighlight>
 +
'''note''': for this event to work you need to add your sprite to the stage (scene).
 +
 
 +
{{Sprite}}

Latest revision as of 11:07, 25 September 2023

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

Description

This event is dispatched when a supported key is pressed. For the list of supported keys, check the KeyCode class. Modifiers can have values of:

Parameters

keyCode: (number) code of the key pressed
realCode: (number) real keyCode underneath
modifiers: (number) modifiers present, or nil if not supported

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).