whoops-wrong-layout
v1.0.0
Published
Corrects wrong layout if a field accepts only English letters
Downloads
3
Maintainers
Readme
🤬 Whoops, wrong layout!
A tiny library that fixes incorrectly selected layout if a field the user types to only accepts English letters, e.g. cardholder name field.
Installation
npm install whoops-wrong-layout
Or just grab the file and do whatever you want with it.
Usage
const whoopsWrongLayout = require('whoops-wrong-layout');
const input = document.querySelector('.js-card-name');
whoopsWrongLayout(input);
Quirks
- Corrects the letters as you type them on your physical keyboard:
- won’t change what’s already in the field,
- won’t mess with pasted text,
- won’t change anything typed from a touch screen (you won’t be typing with a wrong layout from your phone anyway).
- Works with any layout, but will only correct letters that are not in the English alphabet:
- Only corrects letters, doesn’t do anything with numbers, punctuation or any other symbols.
- Doesn’t work in Internet Explorer, but also doesn’t break anything.
Alternatives to consider
Convert Layout by Andrey Sitnik – a different approach to the same problem.