Event.KEY CHAR: Difference between revisions

From GiderosMobile
m Text replacement - "<source" to "<syntaxhighlight"
m Text replacement - "</source>" to "</syntaxhighlight>"
Line 21: Line 21:
end
end
stage:addEventListener(Event.KEY_CHAR, onKeyChar)
stage:addEventListener(Event.KEY_CHAR, onKeyChar)
</source>
</syntaxhighlight>
'''note''': for this event to work you need to add your sprite to the stage (scene).
'''note''': for this event to work you need to add your sprite to the stage (scene).


{{Sprite}}
{{Sprite}}

Revision as of 13:26, 13 July 2023

Available since: Gideros 2016.04
Value: keyChar
Defined by: Sprite

Description

This event is dispatched when a supported key is pressed. For the list of supported keys, check the KeyCode class.

Parameters

text: (String) text of the key char pressed

Example

local textc = TextField.new(nil, "key chars: ")
textc:setScale(4)
textc:setPosition(10, 130)
stage:addChild(textc)

local function onKeyChar(event)
	textc:setText("key chars: "..event.text)
end
stage:addEventListener(Event.KEY_CHAR, onKeyChar)

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