Event.KEY CHAR

From GiderosMobile
Revision as of 22:44, 31 July 2025 by MoKaLux (talk | contribs)

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

type: (String) keyChar
text: (String) text of the key char pressed
modifiers: (number) indicates if a key modifier was also pressed:
   0: no key modifier
   1: SHIFT key modifier
   2: LEFT ALT modifier
   4: CONTROL modifier
   6: RIGHT ALT modifier

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)
	print(e.modifiers)
end
stage:addEventListener(Event.KEY_CHAR, onKeyChar)

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