Skip to content
On this page

Vext Input Store

Pinia store that holds information about mouse/pointer and keyboard input.

State

NameDescriptionTypeValuesDefault
pointerMovetimestamp for most recent pointermove eventnumber-null
pointerMoveTypetype for most recent pointermove eventstring-null
pointerDowntimestamp for most recent pointerdown eventnumber-null
pointerDownTypetype for most recent pointerdown eventstring-null
pointerUptimestamp for most recent pointerup eventnumber-null
pointerUpTypetype for most recent pointerup eventstring-null
mxx position in window for most recent pointermove eventstring-0
myy position in window for most recent pointermove eventstring-0
dxx position in window for most recent pointerdown eventstring-0
dyy position in window for most recent pointerdown eventstring-0
uxx position in window for most recent pointerup eventstring-0
uyy position in window for most recent pointerup eventstring-0
keyDowninformation for most recent keydown eventobject-{ key: "", ctrl: false, shift: false, alt: false, meta: false, time: null }
keyUpinformation for most recent keydown eventobject-{ key: "", ctrl: false, shift: false, alt: false, meta: false, time: null }
keyPressinformation for most recent keydown eventobject-{ key: "", ctrl: false, shift: false, alt: false, meta: false, time: null }

Methods

init

Adds event listeners to the window (once).

emit

Emits an event for this event handler.
@param {String} name - event name
@param {*} data - event data

on

Registers an event handler.
@param {String} name - event name
@param {Function} handler - event callback function
@returns callback handle

off

Removes an event handler for a specific event.
@param {String} name - event name
@param {Number} handler - event callback function handler
@returns true if removed, false otherwise

getPointer

Returns the latest x/y coordinates for a pointer event.
@param {String} event - event type (default move)
@param {HTMLElement} element - relative to which node to retrieve coordinates (default null)
@returns array of latest x/y pointer coordinates

getPointerMove

Returns the latest x/y coordinates for the pointermove event.
@param {HTMLElement} element - relative to which node to retrieve coordinates (default null)
@returns array of latest x/y pointer coordinates

getPointerDown

Returns the latest x/y coordinates for the pointerdown event.
@param {HTMLElement} element - relative to which node to retrieve coordinates (default null)
@returns array of latest x/y pointer coordinates

getPointerUp

Returns the latest x/y coordinates for the pointerup event.
@param {HTMLElement} element - relative to which node to retrieve coordinates (default null)
@returns array of latest x/y pointer coordinates

getKey

Returns the latest x/y information for a key event.
@param {String} event - key event (default down)
@param {Boolean} withMods - whether to include modifiers (default false)
@returns key string if withModes is false, complete object otherwise

getKeyDown

Returns the latest x/y information for the keydown event.
@param {Boolean} withMods - whether to include modifiers (default false)
@returns key string if withModes is false, complete object otherwise

getKeyUp

Returns the latest x/y information for the keyup event.
@param {Boolean} withMods - whether to include modifiers (default false)
@returns key string if withModes is false, complete object otherwise

getKeyPress

Returns the latest x/y information for the keypress event.
@param {Boolean} withMods - whether to include modifiers (default false)
@returns key string if withModes is false, complete object otherwise