Difference between revisions of "Application:getKeyboardModifiers"

From GiderosMobile
m (Text replacement - "</source" to "</syntaxhighlight")
Line 6: Line 6:
 
<source lang="lua">
 
<source lang="lua">
 
(number) = application:getKeyboardModifiers()
 
(number) = application:getKeyboardModifiers()
</source>
+
</syntaxhighlight>
  
 
=== Return values ===
 
=== Return values ===
Line 23: Line 23:
 
print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0)
 
print("CRTL: ", (modifier & KeyCode.MODIFIER_CTRL) > 0)
 
end)
 
end)
</source>
+
</syntaxhighlight>
  
 
'''Checks if Control and Shift keys are pressed'''
 
'''Checks if Control and Shift keys are pressed'''
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)
</source>
+
</syntaxhighlight>
  
 
{{Application}}
 
{{Application}}

Revision as of 16:35, 12 July 2023

Available since: Gideros 2019.5
Class: Application

Description

Returns the current keyboard modifiers. <source lang="lua"> (number) = application:getKeyboardModifiers() </syntaxhighlight>

Return values

Returns (number) the current modifiers bitfield

Examples

Checks if Control key is pressed <source lang="lua"> 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) </syntaxhighlight>

Checks if Control and Shift keys are pressed <source lang="lua"> 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) </syntaxhighlight>