Yuari
Documentation
Docs/Services/Enum.KeyCode

Enum.KeyCode

Virtual-key code tables for input functions, with item enumeration helpers.

Syntax

Enum.KeyCode
Enum.UserInputType
Enum.KeyCode:GetEnumItems() -> { { Name, Value, EnumType } }
Enum.KeyCode:FromValue(value: number) -> { Name, Value, EnumType }?

Parameters

ParameterTypeDescription
valuenumberRaw key or input value passed to FromValue.

Returns

TypeDescription
number | tableBare entries are integers; GetEnumItems returns an array of item tables and FromValue a single item or nil.

Description

Enum.KeyCode.Space and the other entries are plain virtual-key integers, so they can be passed straight to keydown, iskeypressed and the input helpers.

GetEnumItems walks the table and returns item tables with Name, Value and EnumType fields; FromValue returns the first item with a matching value or nil.

KeyCode covers letters, digits, F1–F12, modifiers, arrows, navigation keys, punctuation and the mouse-button gamepad range on UserInputType.

Example

print(Enum.KeyCode.F)                          -- 70
print(Enum.KeyCode:FromValue(70).Name)         -- F
for _, item in ipairs(Enum.KeyCode:GetEnumItems()) do
    if item.Value == Enum.KeyCode.Space then
        print(item.Name)                       -- Space
    end
end

Notes

  • Bare entries are integers, so Enum.KeyCode.A.Value does not exist; use FromValue when an item table is needed.
  • UserInputType: MouseButton1 (1), MouseButton2 (2), MouseButton3 (3), Keyboard (8), Touch (9), Gamepad1–8 (10–17), TextInput (18), InputMethod (19).
  • Added KeyCode entries include Insert, Delete, Home, End, PageUp, PageDown, CapsLock, NumLock, ScrollLock, PrintScreen, brackets, punctuation and LeftSuper/RightSuper.
  • These values are Windows virtual-key codes, not Roblox's KeyCode numbers.