Players choose their own keys for the game's actions (Options → [CONTROLS]); by default W A S D move, Shift runs,
Space jumps, the mouse fires and holds the binoculars, R / B / M / C / Q / 1-9 do the rest. Bind your mod's keys to
something else, and show the player's own key for a game action with keys.binding: the actions are forward back
left right run jump fire zoom binoculars weapon slot1-slot9map call resupply cameraroll trophylock trophydelete.
Calls fn when the key goes down. The game does not see the key, unless fn returns false. With touch, a phone shows an on-screen button for the key (see touch.button); the PC only has the key.
Parameter
Type
key
string
key name
fn
function
fn(e), the key event
optionsoptional
integer|table
a priority, or a table: priority, touch (a touch.button options table: on a phone a button that presses this key; since API 3)
Returns
integer
listener id (events.off)
keys.bind("H", function()
world.god(notworld.god())
game.message("God mode " .. (world.god() and"on"or"off"))
end)
-- the same, with a button on a phonekeys.bind("H", toggleGod, {touch = {label = "GOD"}})