Wrong Layout Input

Notices text typed with the wrong keyboard layout ("ghbdtn" for "привет") and offers the retyped text as a one-tap fix.

StopsText typed in the wrong keyboard layout

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/wrong-layout-input.json

The files land in your project. They're yours to edit.

Usage

wrong-layout-input-usage.tsx
import { WrongLayoutInput } from "@/components/ui/wrong-layout-input"

<WrongLayoutInput label="Reply to Olga" defaultValue="Ghbdtn? rfr ltkf&" />

What it catches

  • Latin gibberish that is a word in another layout (ghbdtn → привет)
  • Non-Latin gibberish that is English in QWERTY (руддщ → hello)
  • Words no real language would spell
  • Names, acronyms, links, code and your ignore list, left alone

Props

WrongLayoutInput props
PropTypeDefault
label

Visible label.

string"Message"
hint

Helper text shown while there is nothing to warn about.

string—
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the new value on every change, including a conversion and its undo.

(value: string) => void—
layouts

Layouts to check against US English QWERTY. Pass only the ones your users have to keep the bundle small.

KeyboardLayout[]KEYBOARD_LAYOUTS
ignore

Words that are never retyped: product names, codes, slang your users write.

string[]EMPTY
delay

Pause in ms before the warning appears while typing. Leaving the field shows it at once.

number600
latinName

Name of the Latin layout in messages.

string"English"
warning

Builds the warning. `typed` is the layout the text was typed in, `meant` the language it reads as.

(typed: string, meant: string) => string(typed, meant) => `Looks like ${meant} typed on the ${typ…
converted

Builds the note shown after converting, with a reminder that the keyboard is probably still wrong.

(meant: string, keyboard: string) => string(meant, keyboard) => `Retyped in ${meant}. Your keyboard …
useLabel

Start of the fix button's accessible name ("Use привет").

string"Use"
keepLabel

Accessible label of the button that keeps the text as typed.

string"Keep as typed"
undoLabel

Label of the button that restores the text as typed.

string"Undo"

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label>; hint via aria-describedby in a polite live region
  • Use button has an aria-label with the converted text; converted text gets a lang attribute
  • Keep and undo are labelled; focus returns to the input
  • Highlight animation respects reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Only the layouts you pass, each mapped against US QWERTY
  • Statistical: short words can be missed or wrongly flagged

What it stops

Text typed in the wrong keyboard layout

Also known as

keyboard layout · wrong layout · transliteration · hindi inscript · russian · search box · punto switcher · language switch

Field type

Dependencies

Pairs well with