Skip to content

KcdMp.mock.key

Fires a key binding’s handlers as if the player had pressed - or let go of - the key.

Runs the handlers registered with KcdMp.onKeyBinding for name with pressed, as the game does when the player’s key for a binding of the game mode goes down or comes up. Any name works: in mock mode no server has declared the bindings. A press and a release are two calls - pressed is true unless it says false.

KcdMp.mock.key(name, pressed?)
Parameter Type
name string the binding’s name
pressed boolean true for the press (the default), false for the release (optional)

nothing

KcdMp.onKeyBinding("map.toggle", (pressed) => { if (pressed) toggleMap(); });
if (KcdMp.env.mock) {
KcdMp.mock.key("map.toggle"); // the press
KcdMp.mock.key("map.toggle", false); // the release
}

KcdMp.onKeyBinding · KcdMp.mock.emit · the Mock mode group of the index