Have ideas to improve npm?Join in the discussion! ¬Ľ

    backspace-disabler

    1.1.3¬†‚Äʬ†Public¬†‚Äʬ†Published

    BACKSPACE DISABLER

    Disable the annoying backward navigation that occurs when the user press the backspace key.

    Features

    • Prevent browser back on backspace (by using preventDefaut())
    • Does not break ability of user to delete content on all known input types
    • Supports contentEditable (in read/edit mode)
    • Allow to apply the behavior globally or on a subtree
    • No dependency

    Installation

    NPM:

    npm install backspace-disabler
    

    Or just copy the code inside index.js into your codebase.

    Usage

    Require it with CommonJS loader (Browserify / Webpack...)

    var BackspaceDisabler = require("backspace-disabler");
     
    // Disable the backspace that triggers backward navigation
    BackspaceDisabler.disable(); 
    // Revert to normal
    BackspaceDisabler.enable();
     
    // Can also be applied to a specific element tree:
    var myWidget = document.getElementById("myWidget");
    BackspaceDisabler.disable(myWidget);
    BackspaceDisabler.enable(myWidget);
     

    Credits

    The ideas of this lib come from StackOverflow

    Install

    npm i backspace-disabler

    DownloadsWeekly Downloads

    391

    Version

    1.1.3

    License

    MIT

    Last publish

    Collaborators

    • avatar