escapeQueue

Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.keyboard

This funciton allows you to register actions to execute when user press the escape key. It will take care of executing the last registered action first, then the others… This function returns a SPromise instance on which you can call the cancel method to unregister your action in the queue. Note that you can get the current queue length by calling escapeQueueLength().

Params

  1. callbacknullFunction

    The callback to call on pressing escape

  2. settings{}Object

    An option object to configure your hotkey. Here’s the list of available settings:

Return

  1. -SPromise

    An SPromise instance that will be resolved when the user has pressed the escape key and that it’s yout turn in the queue

Example

import { escapeQueue } from '@blackbyte/sugar/keyboard'
const promise = escapeQueue();
promise.then(() => {
     // do something...
});

// if you want to cancel your subscription
promise.cancel();

Settings

  1. ctxdocumentHTMLElement

    Specify where to add the listener

  2. id-String

    Specify an id. If specified, will before unqueue the previous item with the same id and add it again

Todo

  • testsnormal