Event.KEY CHAR

From GiderosMobile

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

Description

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

Parameters

type: (String) keyChar
text: (String) text of the key char pressed
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

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)

See also

Event.KEY DOWN
Event.KEY UP