Difference between revisions of "KeyCode"

From GiderosMobile
 
Line 7: Line 7:
 
=== Description ===
 
=== Description ===
 
KeyCode table holds the key code constants. These map directly to a physical key on the keyboard.
 
KeyCode table holds the key code constants. These map directly to a physical key on the keyboard.
 +
 +
=== See also ===
 +
* https://github.com/gideros/gideros/blob/master/libgid/include/ginput.h
 +
* https://github.com/gideros/gideros/blob/master/luabinding/luaapplication.cpp#L664
 +
 +
* https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
  
 
=== Examples ===
 
=== Examples ===

Latest revision as of 23:48, 31 July 2025

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: Object

Description

KeyCode table holds the key code constants. These map directly to a physical key on the keyboard.

See also

Examples

Listening for back button on phones/tablets

stage:addEventListener(Event.KEY_DOWN, function(event)
    if event.keyCode == KeyCode.BACK then
        application:exit()
    end
end)

Full screen

isfullscreen = false

function setFullScreen(xbool)
	application:setFullScreen(xbool)
end

function myKeysPressed()
	self:addEventListener(Event.KEY_DOWN, function(e)
		-- modifier
		local modifier = application:getKeyboardModifiers()
		local alt = (modifier & KeyCode.MODIFIER_ALT) > 0
		-- switch full screen
		if alt and e.keyCode == KeyCode.ENTER then
			isfullscreen = not isfullscreen
			setFullScreen(isfullscreen)
		end
	end)
end

Methods

Events

Constants

KeyCode Constants