whoops-wrong-layout
v0.1.0 keyboard layout change fix correct
🤬 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.
License
npm i [email protected]
Metadata
- MIT
- Whatever
- Oleg Korsunskiy
- released 2/27/2021