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.
Syntax
Section titled “Syntax”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) |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”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}See also
Section titled “See also”KcdMp.onKeyBinding · KcdMp.mock.emit · the Mock mode group of the index
