Skip to content

KcdMp.onPlayerCursor

Registers a function that is told when the player brings up their cursor or takes it away.

The player brings up their cursor with the cursor key (left Alt unless they picked another in the launcher), and a client script with its SetCursorShown. fn(shown) is called at once with the current state, then again at every change. While the cursor is up and no frame holds the mouse cursor, the interface’s own parts (the chat, the scoreboard …) take the clicks; a page that wants them asks for the cursor itself - KcdMp.focus({ cursor: true }) - and gives it back when the player’s cursor goes. The cursor goes away by itself when one of the game’s own menus opens and at a load.

KcdMp.onPlayerCursor(fn)
Parameter Type
fn (shown: boolean) => void called with true while the cursor is up, false while it is not

() => void - a function that takes the handler off again

KcdMp.onPlayerCursor((shown) => {
document.body.classList.toggle("clickable", shown);
KcdMp.focus({ cursor: shown }).catch(() => {});
});

KcdMp.focus · KcdMp.blur · KcdMp.mock.playerCursor · the Focus and visibility group of the index