Skip to content


The key event fires when a key up or key down input is detected. It is preferred that the keyDown and keyUp events are used instead.

--- @param e keyEventData
local function keyCallback(e)
event.register(tes3.event.key, keyCallback)


This event can be filtered based on the keyCode event data.


An event can be claimed by setting e.claim to true, or by returning false from the callback. Claiming the event prevents any lower priority callbacks from being called.

Event Data⚓︎

  • isAltDown (boolean): Read-only. True if either alt key is held.
  • isControlDown (boolean): Read-only. True if either control key is held.
  • isShiftDown (boolean): Read-only. True if either shift key is held.
  • isSuperDown (boolean): Read-only. True if super (Windows key) is held.
  • keyCode (tes3.scanCode): Read-only. The scan code of the key that raised the event. Maps to values in tes3.scanCode table.
  • pressed (boolean): Read-only. True if this is a key down event, false for a key up event.


Example: Show a Message when Ctrl-Z is Pressed

Displays a simple message when Z is pressed while control is held.

local function myOnKeyCallback(e)
    if( e.pressed and e.isControlDown ) then
        tes3.messageBox({ message = "You pressed Ctrl-Z, but you can't undo all your mistakes." })

-- Filter by the scan code to get Z key presses only.
event.register(tes3.event.key, myOnKeyCallback, { filter = tes3.scanCode.z } )