Use this skill for keyboard, pointer, mouse, touch and gamepad input in melonJS. Covers the bindKey action indirection, registerPointerEvent on regions, the isKinematic requirement that silently blocks pointer events, which of several overlapping objects receives an event and how to consume it, world vs screen pointer coordinates, pointer events on 3D meshes, and gamepad mapping onto the same actions. Triggers on: input, bindKey, isKeyPressed, KEY, bindPointer, mouse button, vibrateGamepad, rumble, activeGamepad, registerPointerEvent, releasePointerEvent, pointerdown, pointerup, pointermove, POINTERMOVE, gamepad, bindGamepad, triggerKeyEvent, virtual gamepad, touch controls, joystick, gamepad-plugin, floating stick, floating button, floating joystick, two thumbs, tap to fire, hideAtRest, mobile controls, KEYDOWN, KEYUP, press any key, splash screen, click, touch, drag, POINTERUP, hit test, event propagation, stop propagating, overlapping, which object gets the click, click a mesh, hit3
Capabilities
Keyboard goes through named actions
Do not poll key codes
A poll can miss a press entirely
For a screen where a missed press is a dead end — a splash, a "press…
A mouse button as a key
As with bindGamepad, the key needs its bindKey first, or bindPointer
Pointer events need isKinematic = false
This is the trap
Getting started
Full instructionsInstall the skill, then ask your AI tool for the task in plain words. The full SKILL.md below shows what it covers.
Instructions: SKILL.mdv1.0.7
Input: keyboard, pointer and gamepad
Keyboard goes through named actions
Do not poll key codes. Bind a key to an action string, then poll the action —
this is what lets gamepad and virtual controls map onto the same handling.
import { input } from "melonjs";
input.bindKey(input.KEY.LEFT, "left");
input.bindKey(input.KEY.RIGHT, "right");
input.bindKey(input.KEY.X, "jump", true); // true = locked: one press per keydown
// in update()
if (input.isKeyPressed("left")) { /* … */ }
if (input.isKeyPressed("jump")) { /* fires once per press, not per frame */ }
The third argument to bindKey is lock (default false). Without it,
isKeyPressed stays true for as long as the key is held — correct for movement,
wrong for jump or fire. A locked action stays consumed until the key is released
or you call input.unlockKey("jump"). Use input.keyStatus(action) when you
want the raw held/not-held state regardless of locking.
A poll can miss a press entirely
isKeyPressed is sampled once per frame, and keyup decrements the key's
counter the moment it arrives — locked or not. A press that goes down and up
between two frames therefore leaves the counter back at zero and is never
seen. At 60fps that is anything under ~16ms: rare from a human finger, routine
from a synthetic event, and more likely the slower the frame rate.
For a screen where a missed press is a dead end — a splash, a "press any key",
a notice to acknowledge — listen for the event instead, which cannot be missed:
import { event } from "melonjs";
// action is the bound action name, or undefined for an unbound key
const onKey = (action) => { if (action === "menuSelect") continue(); };
event.on(event.KEYDOWN, onKey); // in onResetEvent
event.off(event.KEYDOWN, onKey); // in onDestroyEvent — it does not self-remove
KEYDOWN fires for every key, bound or not, so matching on action is what
narrows it; it also repeats while the key is held, so guard anything that must
happen once. Keep polling for movement and for a menu cursor, where one step
per press and a key held across a state change are the things that matter.
When the window loses the focus or the page is hidden, every key and
bindPointer button still held is released, since its real release goes to
another window: polling sees it up when the player comes back, and a key still
held then is pressed again by its next keydown. No KEYUP is sent for it,
so code moved by KEYDOWN / KEYUP rather than by polling should also listen
to event.BLUR. A gamepad's presses are left to the gamepad, which is read
every frame.
The full signature is bindKey(keyCode, action, lock?, preventDefault?);
preventDefault defaults to input.preventDefault (itself true). Pass the
fourth argument per binding, or change the global default, for the keys bound
after it, with input.setPreventDefault(false) — assigning
input.preventDefault = false does not work, it is a read-only module
binding. The same flag covers the keys the UI focus takes while a widget has
it, and a button's own bindKey key (20.15.1, read on each press): with it
off, the browser keeps its action for them too, such as scrolling the page
around the game.
A mouse button as a key
bindPointer makes a mouse button press a bound key, so a click fires the same
action and isKeyPressed sees it:
input.bindKey(input.KEY.X, "fire");
input.bindPointer(input.KEY.X); // the left button
input.bindPointer(input.pointer.RIGHT, input.KEY.X); // or another button
input.unbindPointer(input.pointer.RIGHT); // LEFT when omitted
As with bindGamepad, the key needs its bindKey first, or bindPointer
throws no action defined for keycode N. Turning the wheel neither presses
nor releases a bound button's key (before 20.14 it released the left
button's).
Pointer events need isKinematic = false
This is the trap. Renderable.isKinematic defaults to true, and both the
broadphase and the pointer dispatcher skip any candidate whose isKinematic is
still true. The handler registers successfully and simply never fires.
class Button extends Renderable {
constructor(x, y, w, h) {
super(x, y, w, h);
this.isKinematic = false; // ← required
}
onActivateEvent() {
input.registerPointerEvent("pointerdown", this, this.onDown.bind(this));
}
onDeactivateEvent() {
input.releasePointerEvent("pointerdown", this);
}
}
It gates pointer events, not camera.pick(): under a Camera3d, pick()
finds the nearest mesh under a pixel whatever its isKinematic, and a mesh is
left out of it with pickable = false instead (an opt-out, default
true), which touches neither its events nor its collisions — melonjs-3d
compares the two side by side. Do not clear isKinematic just to make a mesh
pickable: that also files it in the collision broadphase.
crate.isKinematic = false; // receives its own pointer events
input.registerPointerEvent("pointerdown", crate, onCrate);
floor.pickable = false; // camera.pick() looks past it...
floor.isKinematic = false; // ...though it still collides
const hit = camera.pick(pointer.gameScreenX, pointer.gameScreenY, app.world);
Container, Camera2d, Draggable, DropTarget and the UI* elements set it
to false for you, and so does giving it a physics body (a bodyDef on any
adapter, or a Body) — so plain Renderable and Sprite subclasses with no
body are the ones that catch people. Before melonJS 20.14, matter-adapter
1.6.0 and planck-adapter 1.7.0, a bodyDef under matter or planck left
isKinematic at true, so set it yourself there.
Register in onActivateEvent and release in onDeactivateEvent, not in the
constructor — pooled objects are reused and would otherwise accumulate handlers.
app.viewport works as a whole-screen region when you want global clicks. Note
it is asked before everything else, not as a fallback after nothing matched:
the dispatcher appends it to the candidate list and walks that list from the
end. So a viewport handler must not return false unless it really means to
swallow every pointer event in the game.
A state has its own viewport: the loading screen's is not the one the game's
state brings. Register on app.viewport once the state is in place (in the
stage's onResetEvent, or after state.change(state.PLAY, true)), not in the
loader.preload callback before it: that handler stays on the loading
screen's viewport and never fires.
The accepted event names are exactly "pointerdown", "pointerup",
"pointermove", "pointercancel", "pointerenter", "pointerover",
"pointerleave" and "wheel". Anything else — "click", "mousedown",
"touchstart" — makes both registerPointerEvent and releasePointerEvent
throw invalid event type. melonJS maps the canonical name onto whichever
mouse/touch events the device actually supports, so you always register the
pointer name.
A region can listen to "pointerup" alone, to act on release: it gets the
release of a press made on it. With several fingers on one region, each finger
that pressed it gets its own pointerup / pointercancel; pointerenter and
pointerleave still follow one pointer per region.
Which object gets the event
The dispatcher collects the regions near the pointer from the broadphase,
bounds-checks each one, orders them the way they are drawn and asks the
topmost first, walking down until something consumes.
A handler consumes by returning false. This is the DOM sense and it reads
backwards: false means handled, and anything else, undefined included, lets
the walk carry on to whatever is underneath.
input.registerPointerEvent("pointerdown", this, () => {
this.fire();
return false; // nothing under this gets the click
});
Three things decide the order, and only the first is obvious:
pos.z, among siblings of one container. Higher is on top, except
under aCamera3d, where the world sorts on"depth"and the regions follow
that sort: afloatingregion is ordered by|z|alone, the smaller on
top, so a dialog at depth 1 is asked before a full-screen region at depth 4.- Across containers, the common ancestor decides.
pos.zis
container-local, sinceautoDepthnumbers each container's children from 1,
so a button atz = 8inside one panel does not outrank a second panel at
z = 2. The pair is resolved by walking both up to their shared parent and
comparing the two siblings there, which is exactly how drawing resolves it.
Raise a whole panel withancestor.moveToTop(panel), not by inflating a
child'sz. - A child is asked before the container holding it, since it draws over it.
Equal z between siblings falls back to child order, lower index on top. Two
callbacks registered on the same region for the same event run
last-registered-first.
Consuming a move also takes the pointer away from the regions below: each
one still holding it gets its pointerleave, because it is covered now and
being inside its own bounds no longer decides. Consuming a press, a release or a
wheel does not, since none of those says where the pointer is.
Meshes under a Camera3d: the ray through the pointer
Under a perspective camera a region's 2D bounds say nothing about where it
draws, so a Mesh (and a Sprite3d, an InstancedMesh, a GLTFModel) is
hit-tested differently (20.16): by the ray through the pointer, against its
triangles. The API does not change — registerPointerEvent on the mesh, and
isKinematic = false as for any region:
crate.isKinematic = false;
input.registerPointerEvent("pointerdown", crate, (pointer) => {
const hit = pointer.hit3d; // where the ray met the crate
spark.pos.set(hit.point.x, hit.point.y);
spark.depth = hit.point.z;
return false; // the floor behind it is not clicked too
});
- Meshes are asked nearest hit first, after the screen-space (
floating)
UI, which draws over the scene. Consuming works as above:return falseand
the mesh behind gets nothing. pointer.hit3dcarriespoint,normal(facing the camera),distance,
triangle,instance(for anInstancedMesh) andrenderable(for a
GLTFModel, the part —hit3d.renderable.nameis the glTF node). It is
nullon a leave, and on any event that is not a mesh's. The record is
reused: copy what you keep past the callback.pointerenter/pointerleavefollow the ray on and off the mesh.- A mesh inside a moved or turned container is hit where it draws, as of the
last frame. One in a container taken out of the world gets nothing. - Each event ray-tests the meshes it can reach, every triangle of them
(each instance of anInstancedMesh). A move only tests the meshes that
listen for moves,pointerenter/pointerleaveor a release: register
onlypointerdownon a ten-thousand-instance forest and moving the mouse
costs nothing; registerpointermoveon it and every move pays for all of
them.
Without registering anything, camera.pick(x, y, app.world) returns the same
record for the nearest mesh under a screen point, and
camera.screenToWorld(x, y, floorY) the point on a level floor — see
melonjs-3d.
World coordinates versus screen coordinates
The pointer carries several, and picking the wrong one produces a feedback loop:
| property | meaning | use for |
|---|---|---|
pointer.gameScreenX / gameScreenY |
canvas-relative position | anything that moves the camera |
pointer.gameWorldX / gameWorldY |
projected into world space | picking and spawning objects |
pointer.gameLocalX / gameLocalY |
relative to the region's ancestor container | hit-testing inside a container |
pointer.gameX / gameY |
context-dependent — see below | region handlers on non-floating regions |
gameX/gameY is not a fixed coordinate space. The dispatcher rewrites it per
candidate just before calling your handler: world coordinates for a normal
region, screen coordinates for a isFloating === true region. On the global
event.POINTERMOVE broadcast it is set to the screen coordinates. When you
need one specific space, read gameWorldX/gameWorldY or
gameScreenX/gameScreenY by name rather than relying on gameX.
Using world coordinates for a camera-orbit drag means the same pixel maps to a
different world point every frame as the camera moves — the drag jumps wildly.
Read gameScreenX / gameScreenY, turn your own yaw and pitch by the change,
and place the camera with camera.orbit(target, yaw, pitch, distance) (see
melonjs-3d).
Pointer move and release outside a region
Region handlers only fire while the pointer is over the region. For a drag,
press on the region, then follow and end it with the global events, which fire
wherever the pointer is: over a region or not, over the canvas or not, and for
a release, even outside the browser window while it was held:
import { event, input } from "melonjs";
input.registerPointerEvent("pointerdown", handle, startDrag);
event.on(event.POINTERMOVE, followDrag);
event.on(event.POINTERUP, endDrag); // let go, anywhere
event.on(event.POINTERCANCEL, dropDrag); // the browser took the pointer away
// and `event.off` the three when the drag's owner goes away
All three hand over a Pointer in screen coordinates (gameScreenX /
gameScreenY, and gameX / gameY set to the same), outside the canvas's
range when the pointer was. POINTERCANCEL is a touch that became a scroll or
a pinch, a pen out of range, a system gesture: a drag that only ends on
POINTERUP stays stuck after one. Usually it should drop the drag rather than
act on it (no shot, no throw). Each finger has its own pointerId.
Do not use a raw globalThis.addEventListener("pointerup", …) for this any
more: it hands over the browser's coordinates, not the game's, and is easy to
forget to remove.
For plain drag-and-drop, Draggable / DropTarget already wire all of this up
(pointerdown / pointerup / pointercancel regions plus a global
POINTERMOVE listener) and emit event.DRAGSTART / event.DRAGEND, and
follow the pointer under any camera, scrolled or zoomed. DRAGEND still
originates from a region handler, so it only fires when the release lands on
the draggable itself.
Gamepad
Gamepad input maps onto the same action strings, so game code does not branch:
input.bindGamepad(0,
{ type: "buttons", code: input.GAMEPAD.BUTTONS.FACE_1 },
input.KEY.X); // → the "jump" action bound above
Order matters: bindGamepad throws no action defined for keycode N if the
keycode has not already been passed to bindKey.
Axes use the same call with a threshold, and bind one half of the axis each
— the sign selects which half:
input.bindGamepad(0, { type: "axes", code: input.GAMEPAD.AXES.LX, threshold: -0.15 }, input.KEY.LEFT);
input.bindGamepad(0, { type: "axes", code: input.GAMEPAD.AXES.LX, threshold: 0.15 }, input.KEY.RIGHT);
threshold is added to the deadzone, it does not replace it. The test is
abs(value) >= deadzone + abs(threshold), so with the default deadzone of 0.1
a threshold of 0.5 does not fire until 0.6 of full travel, and 0.15 fires at
0.25. Pick the number you want the stick to break at and subtract the deadzone.
Raising setGamepadDeadzone moves every axis binding with it.
unbindGamepad(index, button, type?), setGamepadDeadzone(value) and
setGamepadMapping(id, mapping) complete the surface.
Which index to bind
Bindings are per pad index, and the index is plug order, not identity —
nothing reports which pad is "the" controller. Slot 0 is a guess: a wheel, a
spare pad or a keyboard-shaped device left plugged in can hold it for a whole
session while the player presses buttons on slot 1.
So a one-player game binds every slot it will accept to the same actions,
and lets activeGamepad() say which one is in use when something has to go
back the other way:
for (let pad = 0; pad < 4; pad++) {
input.bindGamepad(pad, { type: "buttons", code: input.GAMEPAD.BUTTONS.FACE_1 }, input.KEY.X);
}
input.activeGamepad(); // the last pad to produce a bound input, else the
// first connected one, else -1
Binding spare slots costs nothing: the poll skips a bound index with no pad in
it. activeGamepad() follows bound inputs only, which is what makes it an
answer about the player rather than about electrical noise — a worn stick at
rest reports movement for ever and would otherwise claim to be the active pad.
Rumble
input.vibrateGamepad(input.activeGamepad(), {
duration: 120, strongMagnitude: 0.6, weakMagnitude: 0.9,
});
input.stopGamepadVibration(index); // cut a long effect short
input.hasGamepadVibration(index); // for an options-screen toggle
Safe to call blind: no pad, no motors, or no Gamepad API at all resolves
false and does nothing, so game code never branches on support. Magnitudes
default to full and duration to 200 ms — the underlying web API defaults
every parameter to zero, which makes a bare playEffect a silent no-op. A
second call preempts the first on the same pad, so a rapid series of hits
reads as a rapid series of hits rather than as a queue. For a SUSTAINED rumble issue one effect with a
long duration instead of calling every frame.
Hot-plugging needs no polling of your own — the engine listens for the browser's
own events and republishes them:
import { event } from "melonjs";
event.on(event.GAMEPAD_CONNECTED, (gamepad) => { /* gamepad.id, .index */ });
event.on(event.GAMEPAD_DISCONNECTED, (gamepad) => { /* pause, show a prompt */ });
Bindings survive a disconnect: they are attached to the index, not to the
device, so a pad unplugged and plugged back into the same slot keeps working.
A pad unplugged with a button or the stick held lets go of the keys bound to
them, as releasing them would.
Virtual controls
For on-screen touch controls, use @melonjs/gamepad-plugin (it needs melonJS
20.12 or later) rather than writing them: sticks and buttons drawn over the
game and reported as a pad in a gamepad slot, so the bindGamepad bindings
above answer to them unchanged.
import { GamepadPlugin } from "@melonjs/gamepad-plugin";
// once the application is created: a stick and two buttons, on touch screens
plugin.register(GamepadPlugin, "gamepad", {
buttons: [{ label: "A" }, { label: "B" }],
});
The left stick presses the D-pad buttons (GAMEPAD.BUTTONS.UP ...) in 8
directions and reports AXES.LX/LY; the buttons press FACE_1, FACE_2...
in turn, or a key with { key: input.KEY.SPACE }. Each finger is followed on
its own, a touch starting on the controls does not reach the game, and they
hide while a real pad is in use. plugin.cache.gamepad.visible says whether
they show, to word a prompt ("tap" or a key name).
Sticks and buttons are fixed in a corner by default. floating: true
puts one under the finger wherever it lands inside its area ("half", its
own half of the screen, by default; "screen"; or { x, y, width, height }),
and hideAtRest: true draws it only while held. The usual mobile
two-thumb layout, nothing on screen until touched (1.1):
plugin.register(GamepadPlugin, "gamepad", {
sticks: [{ floating: true, hideAtRest: true }], // left half
buttons: [{ floating: true, hideAtRest: true, label: "A" }], // right half
});
Or one thumb for both: a stick over the whole screen whose quick tap (lifted
within tap.time, 250 ms, without leaning to dpadThreshold) presses a key
or button for one frame, and no button at all:
plugin.register(GamepadPlugin, "gamepad", {
sticks: [{ floating: true, area: "screen", hideAtRest: true,
tap: { key: input.KEY.SPACE } }],
buttons: 0,
});
Where areas overlap, a finger takes the first free control there: fixed
buttons, fixed sticks, floating buttons, floating sticks. So a floating button
on its "half" carves the right half out of a "screen" stick, and several
floating buttons sharing an area split it by distance to where each rests.
Every press lasts at least one frame, so a 15 ms thumb tap still reaches
isKeyPressed, and Safari's pinch gesture is cancelled while the controls
show, so a second thumb works on iOS.
To match the game's artwork (1.2), pass an already-loaded TextureAtlas as
skin to GamepadPlugin, with base / thumb region names on sticks
and region / optional pressed names on buttons. Omitted parts keep
their shapes. Regions scale to the controls' sizes without changing hit areas;
labels, floating controls, opacity, hiding and dimming keep working.
A single key can also be pressed directly, reaching the same actions:
input.triggerKeyEvent(input.KEY.LEFT, true); // press
input.triggerKeyEvent(input.KEY.LEFT, false); // release
Symptom → cause
| symptom | cause |
|---|---|
| a drag stays stuck when released off its region or off the canvas | it ends on the region's own "pointerup", which only fires over it: end it on event.POINTERUP, heard anywhere |
| a drag stays stuck after a touch turned into a scroll or a pinch | it ends on POINTERUP alone: the browser sent a cancel, event.POINTERCANCEL |
| clicks on a 3D mesh land in the wrong place or not at all (before 20.16) | meshes were hit-tested by their 2D bounds, which a perspective camera makes meaningless: update — they are hit-tested by the pointer's ray now |
| a click on a mesh also reaches the floor or mesh behind it | the handler did not return false |
moving the mouse got slow under a Camera3d |
a big mesh or InstancedMesh listens for pointermove / pointerenter / pointerleave: each move ray-tests all its triangles. Listen for presses only, or hover with camera.pick on a smaller set |
pointer.hit3d is null |
not a mesh's event, a pointerleave, or read after the callback returned (the record is reused) |
| pointer handler never fires | isKinematic left at its true default |
under a Camera3d, a full-screen floating region takes the presses meant for a button drawn over it (before 20.16) |
regions were asked by raw z, highest first, though a Camera3d draws the smaller depth on top: update |
| touches never arrive where there is no DOM (nx.js, a Web Worker) | melonJS older than 20.14 listened for mouse events there; update. Touch is then read from TouchEvents dispatched on the canvas given as settings.canvas |
| handlers fire twice, or on dead objects | registered in the constructor instead of onActivateEvent |
| camera drag jumps around | using world coordinates instead of gameScreenX/gameScreenY |
gameX holds screen coords where world coords were expected |
read on event.POINTERMOVE, or on a floating region — use gameWorldX/gameWorldY |
| drag stops when leaving the object | region events end at the region — use event.POINTERMOVE |
| jump fires every frame while held | bindKey without its third lock argument |
| the arrow keys or Space scroll the page around the game, in a portal's frame | the key is read from event.KEYDOWN without a binding, bound with preventDefault false, or bound after input.setPreventDefault(false); before 20.15.1, also the keys the UI focus takes: bind the key, leaving its preventDefault and input.setPreventDefault on |
| the hero keeps walking after an Alt-Tab, until the key is pressed again (before 20.14) | the key's release went to another window: update, held keys are now released on blur |
a region with only a "pointerup" callback never gets it, or the first finger's release is lost with two on one region (before 20.14) |
the release was only delivered to the last pointer to press the region: update |
a key bound with bindPointer never fires once the mouse has entered the canvas (before 20.12) |
the pointer's button bindings were replaced on each event: update |
firing (a key bound with bindPointer) stops while the button is held and the wheel turns (before 20.14) |
a wheel event released the main button's key: update |
| clicks land off target after browser zoom or a move to another screen (before 20.14) | the pointer was scaled by the live pixel ratio against a canvas sized with the old one: update |
a Draggable jumps away when grabbed, and stays stuck dragging, once the camera has moved (before 20.14) |
it mixed screen and world coordinates: update |
invalid event type thrown at registration |
non-pointer name ("click", "mousedown", …) passed to registerPointerEvent |
no action defined for keycode N |
bindGamepad or bindPointer called before bindKey for that keycode |
| floating stick ignores the right half of the screen | its area defaults to "half", its own side — use area: "screen" |
area: "screen" stick still ignores part of the screen |
a floating button's area comes first there — the overlap order is fixed buttons, fixed sticks, floating buttons, floating sticks |
| a quick tap on a stick moves instead of acting | it leaned past dpadThreshold or outlasted tap.time before lifting |
stick has to be pushed well past its threshold before it registers |
threshold is ADDED to the deadzone, not used instead of it |
| one half of a stick does nothing | each half is a separate bindGamepad, chosen by the sign of threshold |
| a key stays pressed after its pad is unplugged, or a stick bound on one side holds its key after coming back to the centre (before 20.12) | update: an unplugged pad lets go of what it held, and a stick lets go when it returns to rest, even just past the centre |
| a widget under an overlapping panel still lights up | the panel consumes no hover: return false from its onOver (presses already stop at UI elements; UIPanel with blocking does both) |
| a widget stays highlighted after the pointer moves onto a panel over it | the panel consumes no pointermove, so nothing takes the pointer off the widget |
a child's big z does not put it in front of another container |
pos.z is container-local — use ancestor.moveToTop() on the container |
| every click in the game stops working | a handler on app.viewport returning false, which is asked first |
a handler on app.viewport never fires |
registered before state.change: it is on the loading screen's viewport, which the game's state replaced. Register it after the state is in place |
| touch controls do nothing | nothing bound to their slot — bindGamepad on the plugin's index (0 by default), or give the buttons a key |
| touch controls never show on a desktop | the gamepad plugin's enabled defaults to device.touch — pass enabled: true to try them there |
Related skills
melonjs-renderables—isKinematicalso gates the physics broadphasemelonjs-ui-and-text—UISpriteElementandUITextButtonhandle this for you
Explore more skills
Browse all- Melonjs PlatformsUse this skill when a melonJS game runs somewhere other than a plain browser tab: a game portal (YouTube Playables,…
- melonjsUse this skill FIRST for any melonJS task, and when asked to build a game for the browser with no engine named; it says…
- Melonjs TilemapsUse this skill for tile maps in melonJS: Tiled maps, LDtk levels, Sprite Fusion maps, and tile layers built in code.…
- Melonjs Particles and TrailsUse this skill for particle effects and motion trails in melonJS — ParticleEmitter configuration, burst versus stream…
- Melonjs Sprites and AnimationUse this skill when creating sprites, playing frame animations, or working with texture atlases in melonJS. Covers…
- Melonjs LightingUse this skill for 2D dynamic lighting in melonJS — Light2d, ambient light on a Stage, multiple lights, and per-pixel…
Security
Reviews (0)
More from melonJS
View source →Frequently asked questions about melonjs-input
What does the melonjs-input skill do?
Use this skill for keyboard, pointer, mouse, touch and gamepad input in melonJS. Covers the bindKey action indirection, registerPointerEvent on regions, the isKinematic requirement that silently blocks pointer events, which of several overlapping objects receives an event and how to consume it, world vs screen pointer coordinates, pointer events on 3D meshes, and gamepad mapping onto the same actions. Triggers on: input, bindKey, isKeyPressed, KEY, bindPointer, mouse button, vibrateGamepad, rumble, activeGamepad, registerPointerEvent, releasePointerEvent, pointerdown, pointerup, pointermove, POINTERMOVE, gamepad, bindGamepad, triggerKeyEvent, virtual gamepad, touch controls, joystick, gamepad-plugin, floating stick, floating button, floating joystick, two thumbs, tap to fire, hideAtRest, mobile controls, KEYDOWN, KEYUP, press any key, splash screen, click, touch, drag, POINTERUP, hit test, event propagation, stop propagating, overlapping, which object gets the click, click a mesh, hit3 It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the melonjs-input skill?
Run `npx @skills-hub-ai/cli install melonjs-input` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/melonjs-input/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does melonjs-input work with?
melonjs-input runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the melonjs-input skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use melonjs-input after installing it?
In Claude Code, type `/melonjs-input` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the melonjs-input skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.
Badge for your README
Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.
[](https://skills-hub.ai/skills/melonjs-input)<a href="https://skills-hub.ai/skills/melonjs-input"><img src="https://skills-hub.ai/api/badges/skill/melonjs-input" alt="Install on Skills Hub"></a>More options in the badge docs.