Reference for keyboard.lua Module 🔗

local keyboard = require("keyboard")

Use these codes to refer to the corresponding keys. That is, if you need the key code for K, write in keyboard.k. The actual key code is available here, but you probably shouldn’t use the number itself in your code.

Letters 🔗

keyboard.aCode: 65
keyboard.bCode: 66
keyboard.cCode: 67
keyboard.dCode: 68
keyboard.eCode: 69
keyboard.fCode: 70
keyboard.gCode: 71
keyboard.hCode: 72
keyboard.iCode: 73
keyboard.jCode: 74
keyboard.kCode: 75
keyboard.lCode: 76
keyboard.mCode: 77
keyboard.nCode: 78
keyboard.oCode: 79
keyboard.pCode: 80
keyboard.qCode: 81
keyboard.rCode: 82
keyboard.sCode: 83
keyboard.tCode: 84
keyboard.uCode: 85
keyboard.vCode: 86
keyboard.wCode: 87
keyboard.xCode: 88
keyboard.yCode: 89
keyboard.zCode: 90

Numbers above Letters 🔗

keyboard.zeroCode: 48
keyboard.oneCode: 49
keyboard.twoCode: 50
keyboard.threeCode: 51
keyboard.fourCode: 52
keyboard.fiveCode: 53
keyboard.sixCode: 54
keyboard.sevenCode: 55
keyboard.eightCode: 56
keyboard.nineCode: 57

Miscellaneous Keys 🔗

keyboard.backspaceCode: 214
keyboard.tabCode: 211
keyboard.enterCode: 208
keyboard.escapeCode: 210
keyboard.escCode: 210
keyboard.deleteCode: 217
keyboard.numlockMinusCode: 173
keyboard.numlockPlusCode: 171
keyboard.numlockSlashCode: 175
keyboard.numlockStarCode: 170
keyboard.numlockAsteriskCode: 170

Arrows and Directions 🔗

keyboard.upCode: 192
keyboard.northCode: 192
keyboard.rightCode: 195
keyboard.eastCode: 195
keyboard.downCode: 193
keyboard.southCode: 193
keyboard.leftCode: 194
keyboard.westCode: 194
keyboard.northEastCode: 197
keyboard.pageUpCode: 197
keyboard.southEastCode: 198
keyboard.pageDownCode: 198
keyboard.southWestCode: 199
keyboard.endKeyCode: 199
keyboard.northWestCode: 196
keyboard.homeCode: 196

Number Pad Numbers 🔗

keyboard.numlock0Code: 160
keyboard.numlock1Code: 161
keyboard.numlock2Code: 162
keyboard.numlock3Code: 163
keyboard.numlock4Code: 164
keyboard.numlock5Code: 165
keyboard.numlock6Code: 166
keyboard.numlock7Code: 167
keyboard.numlock8Code: 168
keyboard.numlock9Code: 169

F Keys 🔗

keyboard.F1Code: 176
keyboard.F2Code: 177
keyboard.F3Code: 178
keyboard.F4Code: 179
keyboard.F5Code: 180
keyboard.F6Code: 181
keyboard.F7Code: 182
keyboard.F8Code: 183
keyboard.F9Code: 184
F10 key does not have a code, and can't be used.
keyboard.F11Code: 186
keyboard.F12Code: 187

Shift and Ctrl 🔗

The Shift and Control keys modify the other keys, by adding 256 and 512, respectively, to the key codes.

If you reference a key by

keyboard.keyName

Then, to get the ID of that key when Shift is held down, write

keyboard.shift.keyName

Similarly, to get the ID of a key when Ctrl is held down, write

keyboard.ctrl.keyName

For Ctrl and Shift at the same time, you can use either of these commands:

keyboard.ctrl.shift.keyName
keyboard.shift.ctrl.keyName

If you happen to need the value for Shift or Ctrl itself, use these:

keyboard.shiftOffsetCode: 256
keyboard.ctrlOffsetCode: 512