API:IsModifierKey
From RoR Wiki
UI Lua API · Interface functions
Version: WAR 1.4.8
Returns whether a keyboard key code is one of the Shift, Ctrl or Alt keys.
isModifier = IsModifierKey(keyCode)
Arguments
- keyCode
number– Keyboard key code, as used by the key-binding data. Fractions are dropped.
Returns
- isModifier
boolean–truefor a modifier key.
Details
- Exactly six codes count as modifiers: 42 (left Shift), 54 (right Shift), 29 (left Ctrl), 157 (right Ctrl), 56 (left Alt) and 184 (right Alt). These are keyboard scan codes. Every other number returns
false. - Only the number is checked; the device the code came from is not known to the function. The stock key-mapping window checks for a keyboard first (see the example).
- The function needs at least one argument and only reads the last one.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From ea_keymappingwindow/source/keymappingwindow.lua:
if( ( deviceId ~= SystemData.InputDevice.KEYBOARD ) or not IsModifierKey( itemId ) )
From the same file:
local function IsOppositeModifierKeyInTable( keyTable, itemId )
if( IsModifierKey( itemId ) )
then
return keyTable[ modiferKeyOppositeLookup[ itemId ] ] ~= nil
else
return false
