Key Layers
A key layer is a set of keyboard keys your mod takes over while it needs them — a fire key for a shooter mode, a menu key for a tool panel, or keys you want the game to ignore. It lives only while your mod is running and never touches the player's own shortcuts (Options > Shortcuts).
Key layers work the same from a UI mod (JavaScript) and from a Lua mod.
01. How it works
| Step | Who | What happens |
|---|---|---|
| Declare | you, once | List your layers in keylayers.json in the mod folder. |
| Activate | your code | keylayer.push puts a layer on top of the stack. Its keys now go to your mod instead of the game. |
| Receive | your code | Each press and release arrives as the keylayer.input event. |
| Deactivate | your code | keylayer.pop takes it off again. |
| Switch | the player | The Mod controls button on the HUD lists every active layer. The player can turn each one, or all of them, off and on. |
Term: "stack"
Several layers — yours and other mods' — can be active at once. They are stacked in the order they were pushed. When two active layers use the same key, the upper layer gets it.
Nothing is saved. Active layers are cleared when the game restarts or the world changes (moving to another city, loading a save), and everything your mod declared goes away when the player disables or deletes the mod.
02. keylayers.json — declare your layers
Put the file in the root of your mod folder (next to mod_manifest.json).
The game reads it whenever the mod is turned on.
{
"layers": [
{
"id": "myshooter.combat",
"bindings": [
{ "key": "F", "action": "fire", "label": "Fire" },
{ "key": "R", "action": "reload" },
{ "key": "E", "modifiers": ["Shift"], "action": "grenade" }
]
},
{
"id": "myshooter.timelock",
"bindings": [
{ "key": "One", "block": true },
{ "key": "Two", "block": true }
]
}
]
}
| Field | Required | Meaning |
|---|---|---|
id | yes | Layer id, used by every command and in the event. Unique across all mods — use yourmod.purpose. 1–64 characters of A-Z a-z 0-9 _ . -. |
bindings[].key | yes | Unreal key name: F, E, F5, SpaceBar, One … Zero, Tilde, … Keyboard keys only. |
bindings[].modifiers | no | ["Ctrl"], ["Shift"], ["Alt"] or a combination. Must match exactly: F does not fire on Ctrl+F. |
bindings[].action | yes* | Name your code receives for this key. Same character rules as id. Not needed with block. |
bindings[].label | no | Text shown to the player in the Mod controls list (any language). Defaults to action. |
bindings[].block | no | true: take the key away from the game and do nothing with it. No event is sent. |
Limits: 32 layers per mod, 64 keys per layer. Escape and
Ctrl+Shift+M are reserved and rejected.
If anything in the file is invalid, the whole file is ignored and a
warning is written to the log ([KeyLayer] <mod>/keylayers.json ignored: …).
If another mod already declared the same id, your layer with that id is
skipped (… is already declared by …).
Blocking keys
Use
"block": trueto stop a game shortcut while your mode runs — for example the time speed keys in a survival mode. You do not write a label: the Mod controls list shows the game shortcut that the key had (in the player's own key setup and language), struck through.
03. Activate and deactivate
// UI mod (app.js)
await inzoi.cli.execute('keylayer.push', { id: 'myshooter.combat' });
// … later
await inzoi.cli.execute('keylayer.pop', { id: 'myshooter.combat' });
// switch preset A -> B in the same stack position (both must be yours)
await inzoi.cli.execute('keylayer.swap', { from: 'myshooter.combat', to: 'myshooter.build' });
-- Lua mod
inzoi.cli.execute("keylayer.push --id=myshooter.combat")
inzoi.cli.execute("keylayer.pop --id=myshooter.combat")
pushon a layer that is already active just moves it to the top.- Keys are taken only in play views (top view, shoulder view, driving, diving…). In the lobby, during loading, in build mode or while typing in a text field, keys go to the game as usual.
- See
keylayer.listto check what is declared and active.
04. Receive key presses — keylayer.input
| Field | Example | Meaning |
|---|---|---|
layer | myshooter.combat | Layer id the key belongs to |
action | fire | action from your binding |
key | F | Unreal key name |
combo | Ctrl+F | Key with modifiers |
phase | pressed / released | Holding a key sends one pressed, then one released. |
The event goes to every mod that listens to it, so always check
layer first.
// UI mod
inzoi.event.on('keylayer.input', function (e) {
if (e.layer !== 'myshooter.combat') { return; }
if (e.action === 'fire') {
if (e.phase === 'pressed') { startFiring(); } else { stopFiring(); }
}
});
-- Lua mod (B1)
inzoi.event.on("keylayer.input", function(e)
if e.layer ~= "myshooter.combat" then return end
if e.action == "fire" then
firing = (e.phase == "pressed")
end
end)
Keys in an active layer never reach the game, so polling them (for example
WasInputKeyJustPressedin Lua) stops working. Use the event.
05. When layers are released
| Situation | What is cleared |
|---|---|
| The player disables or deletes your mod | Your declarations and active layers |
| Your UI view is closed or reloaded | Your mod's active layers (push them again when the view starts) |
| World change (city move, loading a save) | All active layers |
| Game exit or crash | Everything — nothing is saved |
| The player switches a layer off | Only that layer stops taking keys. It keeps its place in the stack and turns back on after your mod pops it and pushes it again |
A good pattern is to push your layers when your mode starts and pop them when it ends, and to push again after a reload.
06. What the player sees
- The Mod controls button (next to the HUD gallery button) gets a small keyboard badge while any layer is active.
- Its panel lists active layers top first, with each layer's keys and labels, and Enable / Disable buttons per layer and for all layers.
- The game's own shortcut hints (for example the
Fprompt on a door) still show the player's normal shortcuts. Your layer only changes what the key does, not what the game HUD prints.