Anvil Scripting Reference
  • Getting started
    • Introduction
  • ๐Ÿš€Examples
    • Create a speed overlay
    • Creating a Clock with ImGui
    • Calculating Distances Tool
  • โš™๏ธ User Settings
    • Make use of our settings API
  • ๐Ÿ“ฆNamespaces
    • engine
    • player
    • key
    • mouse
    • memory
    • draw
    • ImGui
  • ๐ŸงชTypes
    • Vec2
    • Vec3
    • Vec4
    • playerState
    • refDef
    • clientEntity
    • cg
    • usercmd
    • trace
    • dvar
  • ๐Ÿ“„Enums
    • CmdButton
    • ImGuiWindowFlags
    • ImGuiStyleVar
    • ImGuiCol
Powered by GitBook
On this page
  • Methods
  • key.isPressed(keyCode)
  • key.isDown(keyCode)
  1. Namespaces

key

Let's you check if keys are pressed etc.

PreviousplayerNextmouse

Last updated 2 years ago

Key codes can be found here

Methods

key.isPressed(keyCode)

  • keyCode - The code of the key

Returns true if given key is pressed.

Example:

-- Turns around 180 degree if pressing A key
if (key.isPressed(0x41)) then
    local view = player.getView()
    view.y = view.y + 180
    player.setView(view)
end

key.isDown(keyCode)

  • keyCode - The code of the key

Returns true if given key is down right now.

Example:

-- Prints while you hold down D key
while (key.isDown(0x44)) do
    print("D key is being held")
end
๐Ÿ“ฆ
https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
isPressed
isDown