Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
simple-input-events
Advanced tools
Unified mouse & touch event handler for desktop and mobile devices. Filters touch events down to a single finger and offsets the client position so it is relative to the target element.
const createInputEvents = require('simple-input-events');
// create input events with a target element
const event = createInputEvents(canvas);
event.on('down', ({ position, event }) => {
// mousedown / touchstart
console.log(position); // [ x, y ]
console.log(event); // original mouse/touch event
});
event.on('up', ({ position, event }) => {
// mouseup / touchend
console.log(position); // [ x, y ]
console.log(event); // original mouse/touch event
});
event.on('move', ({ position, event, inside, dragging }) => {
// mousemove / touchmove
console.log(position); // [ x, y ]
console.log(event); // original mouse/touch event
console.log(inside); // true if the mouse/touch is inside the element
console.log(dragging); // true if the pointer was down/dragging
});
event.on('tap', ({ position, event }) => {
// mouse / finger was 'clicked'
console.log(position); // [ x, y ]
});
See ./demo.js for an example.
Use npm to install.
npm install simple-input-events --save
handler = createInputEvents([opt])
Creates input events with the below options opt
(also accepts just a DOM element). By default, events are attached to window
.
target
- (default window) the target element to attach events toparent
- (default window) the parent element (usually window) to attach movement events, in order to detect drag events outside the target boundspreventDefault
- (default false) if true, touch events will prevent default actions, typically useful for locking the page in place during tap eventsfiltered
- (default true) if true, finger events will be filtered down to a single finger, instead of allowing multiple fingerspassive
- (default true) if true, non-preventing events will use { passive: true }
as an optiontapDistanceThreshold
- (default 5) a distance threshold in pixels for tap events — if the movement between "down" and "up" is below this threshold, and below the tapDelay
, it will trigger a "tap" eventtapDelay
- (default 300) a delay in milliseconds for tap events — if the time between "down" and "up" is below this delay, and below tapDistanceThreshold
, it will trigger a "tap" eventhandler.on('down', ({ position, event, uv }))
Handles 'down' / pointer start events on the target.
position
is the [ x, y ]
position relative to the top left of the target
event
is the original mouse or touch eventuv
is a normalized UV (unit) space coordinate between 0..1 i.e. position.xy / elementSize.xy
handler.on('up', ({ position, event, inside, uv }))
Handles 'up' / pointer end events on the target.
position
is the [ x, y ]
position relative to the top left of the target
event
is the original mouse or touch eventinside
is true if the event occurred with the pointer inside the target boundsuv
is a normalized UV (unit) space coordinate between 0..1 i.e. position.xy / elementSize.xy
handler.on('move', ({ position, event, inside, dragging, uv }))
Handles 'move' / drag events on the target.
position
is the [ x, y ]
position relative to the top left of the target
event
is the original mouse or touch eventinside
is true if the event occurred with the pointer inside the target bounds (may be outside in touch drag events)dragging
is true if the pointer is considerd 'down' or in a drag stateuv
is a normalized UV (unit) space coordinate between 0..1 i.e. position.xy / elementSize.xy
handler.on('tap', ({ position, event, uv }))
Handles a 'tap' event, which is considered an event where the user pushes and releases quickly (by default below a 300 ms window) with the cursor in the same position (by default within a 10 px radius).
position
is the [ x, y ]
position relative to the top left of the target
event
is the original mouse or touch eventuv
is a normalized UV (unit) space coordinate between 0..1 i.e. position.xy / elementSize.xy
handler.disable()
Detaches events from the target/parent elements.
handler.enable()
Re-attaches events from the target/parent elements if they had been detached.
handler.target
The read-only target element for the input handler.
handler.parent
The read-only parent element for the input handler.
MIT, see LICENSE.md for details.
FAQs
Unified mouse & touch events for desktop and mobile
The npm package simple-input-events receives a total of 16 weekly downloads. As such, simple-input-events popularity was classified as not popular.
We found that simple-input-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.