This function can be used to listen for a 'hold' event on a given node. Initiates a hold timer when the appropriate down event is received and cancels the time if the up event occurs before the timer has expired. If the timer expires, the given handler function is called with the initial down event as the first argument.
Returns a listener object which implements a stopListening() method. Calling stopListening() permanently cancels the listener, removing its event listeners. Alternatively, if the handler function returns true, the listener will be automatically stopped.
The implementation is ideal for key events because successive down events do not reset the hold timer. After calling the handler once, it will not be called again until after an up event is received.
Parameter | Type | Description |
---|---|---|
node | Node on which to listen for events | |
downEvent | String | Type of event that will initiate the hold timer |
upEvent | String | Type of event that will cancel the hold timer |
handler | Function | Function called when the hold timer expires |
timeout | Integer | Length of hold timer in seconds. Defaults to 1. Optional. |
0 Comments