Package openmw.inputΒΆ

openmw.input can be used only in scripts attached to a player.

Usage:

local input = require('openmw.input')

Type input

input.ACTION

Values that can be used with isActionPressed.

input.CONTROLLER_AXIS

Values that can be used with getAxisValue.

input.CONTROLLER_BUTTON

Values that can be passed to onControllerButtonPress/onControllerButtonRelease engine handlers.

input.CONTROL_SWITCH

Values that can be used with getControlSwitch/setControlSwitch.

input.KEY

Key codes.

input.getAxisValue(axisId)

Get value of an axis of a game controller.

input.getControlSwitch(key)

Get state of a control switch.

input.getKeyName(code)

Returns a human readable name for the given key code

input.getMouseMoveX()

Horizontal mouse movement during the last frame.

input.getMouseMoveY()

Vertical mouse movement during the last frame.

input.isActionPressed(actionId)

Is a specific control currently pressed.

input.isAltPressed()

Is Alt key pressed.

input.isControllerButtonPressed(buttonId)

Is a controller button currently pressed.

input.isCtrlPressed()

Is Ctrl key pressed.

input.isIdle()

Is player idle.

input.isKeyPressed(keyCode)

Is a keyboard button currently pressed.

input.isMouseButtonPressed(buttonId)

Is a mouse button currently pressed.

input.isShiftPressed()

Is Shift key pressed.

input.isSuperPressed()

Is Super/Win key pressed.

input.setControlSwitch(key, value)

Set state of a control switch.

Type ACTION

ACTION.Activate
ACTION.AlwaysRun
ACTION.AutoMove
ACTION.Console
ACTION.CycleSpellLeft
ACTION.CycleSpellRight
ACTION.CycleWeaponLeft
ACTION.CycleWeaponRight
ACTION.GameMenu
ACTION.Inventory
ACTION.Journal
ACTION.Jump
ACTION.MoveBackward
ACTION.MoveForward
ACTION.MoveLeft
ACTION.MoveRight
ACTION.QuickKey1
ACTION.QuickKey10
ACTION.QuickKey2
ACTION.QuickKey3
ACTION.QuickKey4
ACTION.QuickKey5
ACTION.QuickKey6
ACTION.QuickKey7
ACTION.QuickKey8
ACTION.QuickKey9
ACTION.QuickKeysMenu
ACTION.QuickLoad
ACTION.QuickMenu
ACTION.QuickSave
ACTION.Run
ACTION.Screenshot
ACTION.Sneak
ACTION.Spell
ACTION.ToggleDebug
ACTION.ToggleHUD
ACTION.TogglePOV
ACTION.ToggleSneak
ACTION.ToggleSpell
ACTION.ToggleWeapon
ACTION.Use
ACTION.Weapon
ACTION.ZoomIn
ACTION.ZoomOut

Type CONTROLLER_AXIS

CONTROLLER_AXIS.LeftX

Left stick horizontal axis (from -1 to 1)

CONTROLLER_AXIS.LeftY

Left stick vertical axis (from -1 to 1)

CONTROLLER_AXIS.LookLeftRight

View direction horizontal axis (RightX by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.LookUpDown

View direction vertical axis (RightY by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.MoveForwardBackward

Movement forward/backward (LeftY by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.MoveLeftRight

Side movement (LeftX by default, can be mapped to another axis in Options/Controls menu)

CONTROLLER_AXIS.RightX

Right stick horizontal axis (from -1 to 1)

CONTROLLER_AXIS.RightY

Right stick vertical axis (from -1 to 1)

CONTROLLER_AXIS.TriggerLeft

Left trigger (from 0 to 1)

CONTROLLER_AXIS.TriggerRight

Right trigger (from 0 to 1)

Type CONTROLLER_BUTTON

CONTROLLER_BUTTON.A
CONTROLLER_BUTTON.B
CONTROLLER_BUTTON.Back
CONTROLLER_BUTTON.DPadDown
CONTROLLER_BUTTON.DPadLeft
CONTROLLER_BUTTON.DPadRight
CONTROLLER_BUTTON.DPadUp
CONTROLLER_BUTTON.Guide
CONTROLLER_BUTTON.LeftShoulder
CONTROLLER_BUTTON.LeftStick
CONTROLLER_BUTTON.RightShoulder
CONTROLLER_BUTTON.RightStick
CONTROLLER_BUTTON.Start
CONTROLLER_BUTTON.X
CONTROLLER_BUTTON.Y

Type CONTROL_SWITCH

CONTROL_SWITCH.Controls

Ability to move

CONTROL_SWITCH.Fighting

Ability to attack

CONTROL_SWITCH.Jumping

Ability to jump

CONTROL_SWITCH.Looking

Ability to change view direction

CONTROL_SWITCH.Magic

Ability to use magic

CONTROL_SWITCH.VanityMode

Vanity view if player doesn't touch controls for a long time

CONTROL_SWITCH.ViewMode

Ability to toggle 1st/3rd person view

Type KEY

KEY.A
KEY.Apostrophe
KEY.B
KEY.BackSlash
KEY.Backspace
KEY.C
KEY.CapsLock
KEY.Comma
KEY.D
KEY.Delete
KEY.DownArrow
KEY.E
KEY.End
KEY.Enter
KEY.Equals
KEY.Escape
KEY.F
KEY.F1
KEY.F10
KEY.F11
KEY.F12
KEY.F2
KEY.F3
KEY.F4
KEY.F5
KEY.F6
KEY.F7
KEY.F8
KEY.F9
KEY.G
KEY.H
KEY.Home
KEY.I
KEY.Insert
KEY.J
KEY.K
KEY.L
KEY.LeftAlt
KEY.LeftArrow
KEY.LeftBracket
KEY.LeftCtrl
KEY.LeftShift
KEY.LeftSuper
KEY.M
KEY.Minus
KEY.N
KEY.NP_0
KEY.NP_1
KEY.NP_2
KEY.NP_3
KEY.NP_4
KEY.NP_5
KEY.NP_6
KEY.NP_7
KEY.NP_8
KEY.NP_9
KEY.NP_Delete
KEY.NP_Divide
KEY.NP_Enter
KEY.NP_Minus
KEY.NP_Multiply
KEY.NP_Plus
KEY.NumLock
KEY.O
KEY.P
KEY.PageDown
KEY.PageUp
KEY.Pause
KEY.Period
KEY.PrintScreen
KEY.Q
KEY.R
KEY.RightAlt
KEY.RightArrow
KEY.RightBracket
KEY.RightCtrl
KEY.RightShift
KEY.RightSuper
KEY.S
KEY.ScrollLock
KEY.Semicolon
KEY.Slash
KEY.Space
KEY.T
KEY.Tab
KEY.U
KEY.UpArrow
KEY.V
KEY.W
KEY.X
KEY.Y
KEY.Z
KEY._0
KEY._1
KEY._2
KEY._3
KEY._4
KEY._5
KEY._6
KEY._7
KEY._8
KEY._9

Type KeyboardEvent

KeyboardEvent.code

Key code.

KeyboardEvent.symbol

The pressed symbol (1-symbol string if can be represented or an empty string otherwise).

KeyboardEvent.withAlt

Is Alt key pressed.

KeyboardEvent.withCtrl

Is Control key pressed.

KeyboardEvent.withShift

Is Shift key pressed.

KeyboardEvent.withSuper

Is Super/Win key pressed.

Type input

Field(s)

#ACTION input.ACTION

Values that can be used with isActionPressed.

#CONTROLLER_AXIS input.CONTROLLER_AXIS

Values that can be used with getAxisValue.

#CONTROLLER_BUTTON input.CONTROLLER_BUTTON

Values that can be passed to onControllerButtonPress/onControllerButtonRelease engine handlers.

#CONTROL_SWITCH input.CONTROL_SWITCH

Values that can be used with getControlSwitch/setControlSwitch.

#KEY input.KEY

Key codes.

input.getAxisValue(axisId)

Get value of an axis of a game controller.

Parameter

Return value

#number: Value in range [-1, 1].

input.getControlSwitch(key)

Get state of a control switch.

I.e. is player able to move/fight/jump/etc.

Parameter

Return value

#boolean:

input.getKeyName(code)

Returns a human readable name for the given key code

Parameter

Return value

#string:

input.getMouseMoveX()

Horizontal mouse movement during the last frame.

Return value

#number:

input.getMouseMoveY()

Vertical mouse movement during the last frame.

Return value

#number:

input.isActionPressed(actionId)

Is a specific control currently pressed.

Input bindings can be changed ingame using Options/Controls menu.

Parameter

Return value

#boolean:

input.isAltPressed()

Is Alt key pressed.

Return value

#boolean:

input.isControllerButtonPressed(buttonId)

Is a controller button currently pressed.

Parameter

Return value

#boolean:

input.isCtrlPressed()

Is Ctrl key pressed.

Return value

#boolean:

input.isIdle()

Is player idle.

Return value

#boolean:

input.isKeyPressed(keyCode)

Is a keyboard button currently pressed.

Parameter

Return value

#boolean:

input.isMouseButtonPressed(buttonId)

Is a mouse button currently pressed.

Parameter

  • #number buttonId : Button index (1 - left, 2 - middle, 3 - right, 4 - X1, 5 - X2)

Return value

#boolean:

input.isShiftPressed()

Is Shift key pressed.

Return value

#boolean:

input.isSuperPressed()

Is Super/Win key pressed.

Return value

#boolean:

input.setControlSwitch(key, value)

Set state of a control switch.

I.e. forbid or allow player to move/fight/jump/etc.

Parameters

Type ACTION

Field(s)

#number ACTION.Activate
#number ACTION.AlwaysRun
#number ACTION.AutoMove
#number ACTION.Console
#number ACTION.CycleSpellLeft
#number ACTION.CycleSpellRight
#number ACTION.CycleWeaponLeft
#number ACTION.CycleWeaponRight
#number ACTION.GameMenu
#number ACTION.Inventory
#number ACTION.Journal
#number ACTION.Jump
#number ACTION.MoveBackward
#number ACTION.MoveForward
#number ACTION.MoveLeft
#number ACTION.MoveRight
#number ACTION.QuickKey1
#number ACTION.QuickKey10
#number ACTION.QuickKey2
#number ACTION.QuickKey3
#number ACTION.QuickKey4
#number ACTION.QuickKey5
#number ACTION.QuickKey6
#number ACTION.QuickKey7
#number ACTION.QuickKey8
#number ACTION.QuickKey9
#number ACTION.QuickKeysMenu
#number ACTION.QuickLoad
#number ACTION.QuickMenu
#number ACTION.QuickSave
#number ACTION.Run
#number ACTION.Screenshot
#number ACTION.Sneak
#number ACTION.Spell
#number ACTION.ToggleDebug
#number ACTION.ToggleHUD
#number ACTION.TogglePOV
#number ACTION.ToggleSneak
#number ACTION.ToggleSpell
#number ACTION.ToggleWeapon
#number ACTION.Use
#number ACTION.Weapon
#number ACTION.ZoomIn
#number ACTION.ZoomOut

Type CONTROLLER_AXIS

Ids of game controller axises.

Used as an argument in getAxisValue.

Field(s)

#number CONTROLLER_AXIS.LeftX

Left stick horizontal axis (from -1 to 1)

#number CONTROLLER_AXIS.LeftY

Left stick vertical axis (from -1 to 1)

#number CONTROLLER_AXIS.LookLeftRight

View direction horizontal axis (RightX by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.LookUpDown

View direction vertical axis (RightY by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.MoveForwardBackward

Movement forward/backward (LeftY by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.MoveLeftRight

Side movement (LeftX by default, can be mapped to another axis in Options/Controls menu)

#number CONTROLLER_AXIS.RightX

Right stick horizontal axis (from -1 to 1)

#number CONTROLLER_AXIS.RightY

Right stick vertical axis (from -1 to 1)

#number CONTROLLER_AXIS.TriggerLeft

Left trigger (from 0 to 1)

#number CONTROLLER_AXIS.TriggerRight

Right trigger (from 0 to 1)

Type CONTROLLER_BUTTON

Field(s)

#number CONTROLLER_BUTTON.A
#number CONTROLLER_BUTTON.B
#number CONTROLLER_BUTTON.Back
#number CONTROLLER_BUTTON.DPadDown
#number CONTROLLER_BUTTON.DPadLeft
#number CONTROLLER_BUTTON.DPadRight
#number CONTROLLER_BUTTON.DPadUp
#number CONTROLLER_BUTTON.Guide
#number CONTROLLER_BUTTON.LeftShoulder
#number CONTROLLER_BUTTON.LeftStick
#number CONTROLLER_BUTTON.RightShoulder
#number CONTROLLER_BUTTON.RightStick
#number CONTROLLER_BUTTON.Start
#number CONTROLLER_BUTTON.X
#number CONTROLLER_BUTTON.Y

Type CONTROL_SWITCH

Field(s)

#string CONTROL_SWITCH.Controls

Ability to move

#string CONTROL_SWITCH.Fighting

Ability to attack

#string CONTROL_SWITCH.Jumping

Ability to jump

#string CONTROL_SWITCH.Looking

Ability to change view direction

#string CONTROL_SWITCH.Magic

Ability to use magic

#string CONTROL_SWITCH.VanityMode

Vanity view if player doesn't touch controls for a long time

#string CONTROL_SWITCH.ViewMode

Ability to toggle 1st/3rd person view

Type KEY

Field(s)

#number KEY.A
#number KEY.Apostrophe
#number KEY.B
#number KEY.BackSlash
#number KEY.Backspace
#number KEY.C
#number KEY.CapsLock
#number KEY.Comma
#number KEY.D
#number KEY.Delete
#number KEY.DownArrow
#number KEY.E
#number KEY.End
#number KEY.Enter
#number KEY.Equals
#number KEY.Escape
#number KEY.F
#number KEY.F1
#number KEY.F10
#number KEY.F11
#number KEY.F12
#number KEY.F2
#number KEY.F3
#number KEY.F4
#number KEY.F5
#number KEY.F6
#number KEY.F7
#number KEY.F8
#number KEY.F9
#number KEY.G
#number KEY.H
#number KEY.Home
#number KEY.I
#number KEY.Insert
#number KEY.J
#number KEY.K
#number KEY.L
#number KEY.LeftAlt
#number KEY.LeftArrow
#number KEY.LeftBracket
#number KEY.LeftCtrl
#number KEY.LeftShift
#number KEY.LeftSuper
#number KEY.M
#number KEY.Minus
#number KEY.N
#number KEY.NP_0
#number KEY.NP_1
#number KEY.NP_2
#number KEY.NP_3
#number KEY.NP_4
#number KEY.NP_5
#number KEY.NP_6
#number KEY.NP_7
#number KEY.NP_8
#number KEY.NP_9
#number KEY.NP_Delete
#number KEY.NP_Divide
#number KEY.NP_Enter
#number KEY.NP_Minus
#number KEY.NP_Multiply
#number KEY.NP_Plus
#number KEY.NumLock
#number KEY.O
#number KEY.P
#number KEY.PageDown
#number KEY.PageUp
#number KEY.Pause
#number KEY.Period
#number KEY.PrintScreen
#number KEY.Q
#number KEY.R
#number KEY.RightAlt
#number KEY.RightArrow
#number KEY.RightBracket
#number KEY.RightCtrl
#number KEY.RightShift
#number KEY.RightSuper
#number KEY.S
#number KEY.ScrollLock
#number KEY.Semicolon
#number KEY.Slash
#number KEY.Space
#number KEY.T
#number KEY.Tab
#number KEY.U
#number KEY.UpArrow
#number KEY.V
#number KEY.W
#number KEY.X
#number KEY.Y
#number KEY.Z
#number KEY._0
#number KEY._1
#number KEY._2
#number KEY._3
#number KEY._4
#number KEY._5
#number KEY._6
#number KEY._7
#number KEY._8
#number KEY._9

Type KeyboardEvent

The argument of onKeyPress/onKeyRelease engine handlers.

Field(s)

#string KeyboardEvent.code

Key code.

#string KeyboardEvent.symbol

The pressed symbol (1-symbol string if can be represented or an empty string otherwise).

#boolean KeyboardEvent.withAlt

Is Alt key pressed.

#boolean KeyboardEvent.withCtrl

Is Control key pressed.

#boolean KeyboardEvent.withShift

Is Shift key pressed.

#boolean KeyboardEvent.withSuper

Is Super/Win key pressed.