hold-event

Provides key hold-start, holding, hold-end and other events.

Key press and hold

The 1st argument is a KeyboardEvent.code.

const keyLeft = new holdEvent.KeyboardKeyHold( 'ArrowLeft' );

keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_START, ( event ) => console.log( event ) );
keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLDING, ( event ) => console.log( event ) );
keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_END, ( event ) => console.log( event ) );

Element press and hold

const $button = document.getElementById( 'button' )
const buttonHold = new holdEvent.ElementHold( $button );

buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_START, ( event ) => console.log( event ) );
buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLDING, ( event ) => console.log( event ) );
buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_END, ( event ) => console.log( event ) );