Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slorber/backspace-disabler
Disable the annoying browser backward navigation when the user press the backspace key
https://github.com/slorber/backspace-disabler
Last synced: 4 days ago
JSON representation
Disable the annoying browser backward navigation when the user press the backspace key
- Host: GitHub
- URL: https://github.com/slorber/backspace-disabler
- Owner: slorber
- License: mit
- Created: 2015-08-06T17:58:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-29T15:59:15.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T13:57:12.001Z (14 days ago)
- Language: JavaScript
- Homepage: https://sebastienlorber.com
- Size: 10.7 KB
- Stars: 11
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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...)
```javascript
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](http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back)
# Hire a freelance expert
Looking for a React/ReactNative freelance expert with more than 5 years production experience?
Contact me from my [website](https://sebastienlorber.com/) or with [Twitter](https://twitter.com/sebastienlorber).