Event.KEY CHAR

From GiderosMobile
Revision as of 04:50, 21 March 2023 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2016.04<br/> '''Value:''' keyChar<br/> '''Defined by:''' Sprite<br/> === Description === This event is dispatched when a supporte...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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. Modifiers can have values of:

Parameters

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

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