Difference between revisions of "Application:getKeyboardModifiers"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
(One intermediate revision by the same user not shown) | |||
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
Returns the current keyboard modifiers. | Returns the current keyboard modifiers. | ||
− | < | + | <syntaxhighlight lang="lua"> |
(number) = application:getKeyboardModifiers() | (number) = application:getKeyboardModifiers() | ||
− | </ | + | </syntaxhighlight> |
=== Return values === | === Return values === | ||
Line 13: | Line 13: | ||
=== Examples === | === Examples === | ||
'''Checks if Control key is pressed''' | '''Checks if Control key is pressed''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
stage:addEventListener(Event.KEY_DOWN, function(e) | stage:addEventListener(Event.KEY_DOWN, function(e) | ||
local modifier = application:getKeyboardModifiers() | local modifier = application:getKeyboardModifiers() | ||
Line 23: | Line 23: | ||
print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0) | print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0) | ||
end) | end) | ||
− | </ | + | </syntaxhighlight> |
'''Checks if Control and Shift keys are pressed''' | '''Checks if Control and Shift keys are pressed''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
stage:addEventListener(Event.KEY_DOWN, function(e) | stage:addEventListener(Event.KEY_DOWN, function(e) | ||
local modifier = application:getKeyboardModifiers() | local modifier = application:getKeyboardModifiers() | ||
Line 36: | Line 36: | ||
print("CRTL & SHIFT: ", modifier & KeyCode.MODIFIER_CTRL > 0 and modifier & KeyCode.MODIFIER_SHIFT > 0) | print("CRTL & SHIFT: ", modifier & KeyCode.MODIFIER_CTRL > 0 and modifier & KeyCode.MODIFIER_SHIFT > 0) | ||
end) | end) | ||
− | </ | + | </syntaxhighlight> |
{{Application}} | {{Application}} |
Latest revision as of 16:36, 12 July 2023
Available since: Gideros 2019.5
Class: Application
Description
Returns the current keyboard modifiers.
(number) = application:getKeyboardModifiers()
Return values
Returns (number) the current modifiers bitfield
Examples
Checks if Control key is pressed
stage:addEventListener(Event.KEY_DOWN, function(e)
local modifier = application:getKeyboardModifiers()
print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0)
end)
stage:addEventListener(Event.KEY_UP, function(e)
local modifier = application:getKeyboardModifiers()
print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0)
end)
Checks if Control and Shift keys are pressed
stage:addEventListener(Event.KEY_DOWN, function(e)
local modifier = application:getKeyboardModifiers()
print("CRTL & SHIFT: ", modifier & KeyCode.MODIFIER_CTRL > 0 and modifier & KeyCode.MODIFIER_SHIFT > 0)
end)
stage:addEventListener(Event.KEY_UP, function(e)
local modifier = application:getKeyboardModifiers()
print("CRTL & SHIFT: ", modifier & KeyCode.MODIFIER_CTRL > 0 and modifier & KeyCode.MODIFIER_SHIFT > 0)
end)
- Application:canOpenUrl
- Application:checkPermission
- Application:configureFrustum
- Application:enableDrawInfo
- Application:enableOnDemandDraw
- Application:exit
- Application:get
- Application:getApiVersion
- Application:getAppId
- Application:getBackgroundColor
- Application:getClipboard
- Application:getContentHeight
- Application:getContentWidth
- Application:getDeviceHeight
- Application:getDeviceInfo
- Application:getDeviceName
- Application:getDeviceOrientation
- Application:getDeviceSafeArea
- Application:getDeviceWidth
- Application:getFps
- Application:getKeyboardModifiers
- Application:getLanguage
- Application:getLocale
- Application:getLogicalBounds
- Application:getLogicalHeight
- Application:getLogicalScaleX
- Application:getLogicalScaleY
- Application:getLogicalTranslateX
- Application:getLogicalTranslateY
- Application:getLogicalWidth
- Application:getNativePath
- Application:getOrientation
- Application:getProjectProperties
- Application:getScaleMode
- Application:getScreenDensity
- Application:getTextureMemoryUsage
- Application:isPlayerMode
- Application:openUrl
- Application:requestPermissions
- Application:set
- Application:setBackgroundColor
- Application:setClipboard
- Application:setEventMerging
- Application:setFps
- Application:setFullScreen
- Application:setKeepAwake
- Application:setKeyboardVisibility
- Application:setLogicalDimensions
- Application:setOrientation
- Application:setScaleMode
- Application:setTextInput
- Application:setWindowSize
- Application:vibrate