@zaisma/input
Input for every device: keyboard and mouse, touch and gamepads read as one set of actions the game names, plus where the player moves and how far they turn the view, so a game plays on a phone, a laptop and a controller with no handling of its own for each.
- Kind
- Foundation
- Built on
- @zaisma/standard
- Version
- 1.1.0
- Licence
- MIT, open source
- By
- btc7274
- Rated
- No ratings yet
ShellCopied
npx @zaisma/cli pieces add @zaisma/inputWhat it needs
Nothing: it stands on its own.
Fits is said only for what Zaisma ran together. Not tested means nobody at Zaisma has.
Settings and hooks
Everything a game can change without editing the piece, so it moves to a newer version and keeps the game's changes.
- input_enabledWhether the player's input is read. Turned off (while a menu or a chat box is open), moving and turning stop, every action is let go and the page's own keys work again.On or off, starts onSetting
- mouse_look_modeHow the mouse turns the view: pointer_lock hides the pointer on a click and every move turns; hold_button turns only while mouse_look_button is held, keeping the pointer for menus; off leaves the mouse to the game.One of pointer_lock, hold_button, off; starts at pointer_lockSetting
- mouse_look_buttonThe mouse button held to turn the view when mouse_look_mode is hold_button.One of left, right, middle; starts at rightSetting
- mouse_look_rad_per_pxHow far the view turns for each pixel the mouse moves, in radians: the mouse sensitivity.Number, 0.0001 to 0.05, starts at 0.0022Setting
- raw_mouse_enabledWhether a locked mouse is read as it moves, without the computer's pointer acceleration, where the browser allows it, so the same hand movement always turns the same amount.On or off, starts onSetting
- invert_look_y_enabledWhether pushing up looks down, on every device.On or off, starts offSetting
- touch_controls_enabledWhether the piece draws its touch controls (the stick and a button for each action with a touch label). Off, touches still move and turn the view, and the game draws its own buttons and presses actions with setTouchHeld.On or off, starts onSetting
- touch_stick_radius_pxHow far the thumb moves from where it landed to push the stick all the way, in CSS pixels.Number, 24 to 160, starts at 56Setting
- touch_stick_dead_zone_pctHow much of the stick's radius a thumb moves before the character starts to move, so a resting thumb stands still.Number, 0 to 60, starts at 10Setting
- touch_stick_follows_enabledWhether the stick follows a thumb that slides past its edge, so turning back responds at once instead of crossing the whole stick.On or off, starts onSetting
- touch_stick_zone_pctHow much of the screen's width, from the left, starts the stick where a thumb lands; a touch anywhere else turns the view.Number, 10 to 90, starts at 50Setting
- touch_look_rad_per_pxHow far the view turns for each pixel a finger drags, in radians.Number, 0.0005 to 0.05, starts at 0.006Setting
- touch_button_size_pxHow wide the first touch button is, in CSS pixels; the others are a little smaller around it.Number, 40 to 140, starts at 72Setting
- gamepad_move_dead_zone_pctHow far the move stick is pushed before the character moves, so a worn stick never drifts. Past it, moving starts from nothing.Number, 0 to 60, starts at 15Setting
- gamepad_look_dead_zone_pctHow far the look stick is pushed before the view turns.Number, 0 to 60, starts at 12Setting
- gamepad_look_rad_per_secHow fast the view turns with the look stick pushed all the way, in radians a second.Number, 0.1 to 20, starts at 3.2Setting
- gamepad_fine_aim_pctHow much finer small pushes of the look stick are than big ones, for aiming: at 0 the view turns as far as the stick is pushed; higher keeps small pushes slow while a full push still turns at full speed (the push is raised to the power 1 + 3 × this ÷ 100).Number, 0 to 100, starts at 20Setting
- gamepad_trigger_press_pctHow far a trigger is pulled before an action bound to it is held. How far it's pulled is always read with pressedPctOf.Number, 5 to 95, starts at 40Setting
- gamepad_sticks_swapped_enabledWhether the right stick moves and the left one turns the view, for players who hold it that way.On or off, starts offSetting
- gamepad_label_styleWhich controller's names labelsOf gives gamepad buttons: auto names them after the gamepad in the player's hands.One of auto, xbox, playstation, nintendo; starts at autoSetting
- rumble_enabledWhether rumble shakes a gamepad, or a phone that can vibrate. Off, rumble does nothing.On or off, starts onSetting
- device_changedTold during update when the player starts using another kind of device, with its kind: keyboard_mouse, touch or gamepad. Change the prompts on screen here.Event
- action_pressedTold during update when an action is pressed, with { actionName, deviceKind }, in the order the game named its actions.Event
- action_releasedTold during update when an action is let go, with { actionName, deviceKind }.Event
- pointer_lock_changedTold when the pointer is locked to the game or let go (the player pressed Escape), with whether it's locked now. Show a click-to-play prompt here.Event
- before_moveAsked during update with where the player wants to move, { x, y }; answer another { x, y } to change it (reversed controls, a slow while aiming), or nothing to leave it. Its length is kept to 1 at most.Decision
- before_lookAsked during update with how far the player turned the view this frame in radians, { x, y }; answer another { x, y } to change it (a slower turn while aiming, aim assist), or nothing to leave it.Decision
None.
Versions
- 1.1.0Nov 29, 2026 · 6 files · 88 KBNewest
No version has passed its checks yet.







