---
title: "Comment by c-wind on \"Lang Switcher: A Keyboard Layout Switcher With an Undo Key\" | Hashnode"
description: "The keystroke-buffer approach is the right one for layout conversion; a character-level table would fall over on Shift+2 immediately, as you show. The part I wo"
url: "https://hashnode.com/posts/lang-switcher-keyboard-layout-switcher-undo-key/6af32351cbcd6f3a5ecbe931/comment/6af466cb852156dd76954b44"
---

[Discussion](https://hashnode.com/posts/lang-switcher-keyboard-layout-switcher-undo-key/6af32351cbcd6f3a5ecbe931)

Comment [Lang Switcher: A Keyboard Layout Switcher With an Undo Key](https://hashnode.com/posts/lang-switcher-keyboard-layout-switcher-undo-key/6af32351cbcd6f3a5ecbe931)

[c-wind](https://hashnode.com/@c-wind)

[6d ago](https://hashnode.com/posts/lang-switcher-keyboard-layout-switcher-undo-key/6af32351cbcd6f3a5ecbe931/comment/6af466cb852156dd76954b44)

The keystroke-buffer approach is the right one for layout conversion; a character-level table would fall over on Shift+2 immediately, as you show. The part I would tighten is the fail-open on unknown field types: if UI Automation can't tell whether a field is a password, I'd rather treat it as one (no buffer, thud on Pause) than risk keeping keystrokes from a custom password widget. The console rule of never using Ctrl+C to read a selection is the same kind of conservative default, and it fits the rest of the design well.

[Panda Koder](https://hashnode.com/@panda-pishet-kod)

[5d ago](https://hashnode.com/posts/lang-switcher-keyboard-layout-switcher-undo-key/6af32351cbcd6f3a5ecbe931/comment/6af466cb852156dd76954b44#reply-6af57eebb354e8da918b19e4)

Thanks — glad the Shift+2 example made the case.

I'm keeping the default as it is, on purpose. If "unknown" meant "password", the program would fall silent in most Electron apps and web pages, where UI Automation answers slowly — it would stop doing its one job exactly where people type the most.

Your worry about missed password fields was fair, though, and not only in theory. Up to 1.4.4 the program failed to recognise password fields in WinForms programs, and in Edge, Chrome and Firefox when you reached the field with Tab. That wasn't a timeout: the checks gave a wrong answer, so a fail-closed default wouldn't have caught it either. 1.5.0 fixes it — the program now listens to UI Automation focus events as well as asking EM\_GETPASSWORDCHAR. And in a password field, Pause now only switches the layout; it never converts what was typed.

What it keeps in ordinary fields stays in memory only: never written to disk, a log or a crash dump, and overwritten with zeros at every reset. If an app has its own password widget that slips past the checks, put the app on the exclusion list, and nothing typed there is kept at all.
