Increment/decrement number values in text inputs using up and down arrow keys.
No external dependencies (<1kB gzipped).
Vanilla API:
smartNumberInputs.enable(DOMElement element);
smartNumberInputs.enable(DOMElement[] elements);
smartNumberInputs.enable(NodeList elements);
smartNumberInputs.enable(HTMLCollection elements);
Manually attaching the event handler to affect dynamically created inputs using jQuery:
$(document).on('keydown', 'input', smartNumberInputs.eventHandler);
NPM:
const smartNumberInputs = require('smart-number-inputs');
npm test
Only unit tests:
npm run test:unit
Only browser tests:
npm run test:browser
npm run build
Modern browsers.
Utilizes addEventListener
(if using smartNumberInputs.enable
) and DOMElement.setSelectionRange
. Both of these can be polyfilled if support for ancient browsers is desired.
Built by @codeclown to be used in MailDeveloper.
Browser testing provided for free by Sauce Labs. Thanks!
MIT