Transmorphic Keyboard Layouts

In the world of keyboard layouts, there are a few layouts which I have come to call, for lack of a better word, transmorphic keyboard layouts. In plain English, this is defined as keyboard layouts whose character mappings change based on the applied modifier keys.

To explain this in more practical terms: with a transmorphic keyboard layout, when you press some key by itself (without any modifiers like Shift, Ctrl or Alt) it outputs some character, for example F. But when you press that same key in combination with one or more modifiers such as Ctrl, it could result in an input event with a different character, for example Ctrl+U.

One well-known example of a transmorphic keyboard layout is the Dvorak-Qwerty ⌘ on MacOS X. This layout uses the Dvorak layout for unmodified keystrokes, but unlike the "normal" Dvorak layout, it actually retains the QWERTY layout for keys when pressed in combination with the modifier. So, for example, pressing the leftmost key in the top row (the one immediately to the right of the TAB key) without any modifiers will output an apostrophe (based on the Dvorak layout) but pressing that same key in combination with the modifier will invoke ⌘+Q (based on QWERTY layout). This keyboard layout is built-in on MacOS X; there is no equivalent built-in layout on Windows, but several third-party/enthusiast implementations exist for both Windows and Linux.

So why on Earth do people want to do this?

Well, specifically in the case of Dvorak, there are two main reasons:

  1. Ergonomics when using a mouse and keyboard in combination. Many of the standard QWERTY-based keyboard shortcuts such as Ctrl+Z, Ctrl-X, Ctrl-C and Ctrl-V are located in the lower-left corner of the keyboard so that the user can invoke them using only one hand, while the other hand works the mouse. For anyone doing graphics editing, word processing or programming on a regular basis, much time is spent using the mouse pointer simultaneously to indicate location while using the clipboard keyboard shortcuts to move, copy or otherwise rearrange editable content. If these commonly used keyboard shortcuts were remapped to their Dvorak equivalents, they would be in physically awkward positions, often requiring two hands to invoke.

  2. Visual orientation when using the Dvorak keyboard layout but with a keyboard with QWERTY-based printed letters on it. Some users of Dvorak change out their keyboards to have the printed letters reflect the Dvorak layout, but many instead choose to start ignoring the printed letters on the keyboard while typing, both as an aid to learning to not look down at the keyboard while typing, and also because it helps to be able to effortlessly work on machines where you don't get to choose your keyboard. Oftentimes, our fingers learn to naturally find the correct characters when typing fluent text, but it's harder to locate a single key in isolation, such as when entering a keyboard shortcut. In these situations it helps to be able to look at the physical keyboard for orientation; if the Ctrl-modified keys are where the QWERTY-printed keyboard says they should be, we can simply look and press.

Of course, for other transmorphic keyboard layouts, other reasons may apply.

Transmorphic keyboard layouts are fully supported in both the MacOS X and Windows input models, and there are several layouts for both operating systems that take advantage of this support for one reason or another.

Applications sometimes make incorrect assumptions about this in their custom keyboard handling logic. Some applications incorrectly assume that keyboard layouts are always non-transmorphic, i.e. that the unmodified and unmodified character maps of any given physical key are always the same. As a result, these applications are sometimes written to handle a modified keystroke by checking the modifier and the physical key's unmodified character mapping separately. Using our above example, this would make the application see a ⌘+Q keystroke as ⌘+' instead, and thus invoke a command that the user does not expect.

This is somewhat understandable, because in the vast majority of cases this assumption holds true; most users do not use a transmorphic keyboard layout. Nevertheless, it can make life quite frustrating for users who do.

A few examples of well-known applications that do the wrong thing:

  • Adobe Acrobat (on both Mac and Windows)
  • Adobe Photoshop for Windows
  • Visual Studio Code for Mac (workaround still exists by reverting to "legacy" keyboard handling)
  • Visual Studio Code for Windows (shortcuts work correctly but the shortcut editor does not)
  • Microsoft Office for Mac
  • Microsoft Word for Windows (most common keyboard shortcuts get initialized with incorrect defaults)
  • SQL Server Management Studio

Recently, another notable issue has recently been brought to my attention; that's actually part of the reason why I decided to create this write-up. The Windows versions of the Chrome, Firefox and Opera web browsers all have implementations of the KeyboardEvent JavaScript API that incorrectly disregard the possibility of a transmorphic keyboard layout and, as a result, reflect the wrong KeyboardEvent.key value to web applications that use this API to handle client-side keyboard events.

The only browser on Windows that actually handles this correctly is Edge.

This can be seen quite clearly using W3C's excellent Keyboard Event Viewer tool. Here are some examples of pressing Ctrl+F using a transmorphic Dvorak-Qwerty keyboard layout on Windows:

Transmorphic keyboard events on Chrome
Transmorphic keyboard events on Edge
Transmorphic keyboard events on Opera
Transmorphic keyboard events on Firefox

Among the notable web applications affected by this issue is GitHub's markdown editor (which is used for writing PR descriptions, commenting on issues, etc.) is unusable on Windows for anyone using a transmorphic keyboard layout except if using Edge. I have been in touch with GitHub about this issue over the past few weeks, and they have (quite justifiably IMO) concluded this to be a bug in the aforementioned browsers.

I hereby call on the developers of Chrome, Firefox and Opera to fix this shortcoming of their implementations. To reproduce, you are free to download my transmorphic keyboard layout from here, and I am happy to help in any way that I can.

Leave a comment