YubiKey OTP, Dvorak input, Karabiner Elements, and Goku
Upd:
Table of Contents
Introduction
I use a YubiKey for 2FA. I also use the Dvorak keyboard layout on my desktop machines. The YubiKey OTP emulates a USB keyboard to input the OTP, which means its beholden to the system input layout. This means when you set up the key with Dvorak and try to use the YubiKey on a device whose input is set to QWERTY then the key won't work. This is an acute problem using it with NFC on a smartphone.
For macOS, which is my primary OS, there two good guides out there on remapping the relevant keys for the YubiKey device with Karabiner Elements:
- Using YubiKey on macOS with Colemak or other "weird" keyboard layouts
- How I got a YubiKey working with a Dvorak keyboard and Karabiner-Elements
Since I use GokuRakuJoudo to compile an EDN format Karabiner config for easier editing, I needed to rewrite the configuration for the right format.
The guides give you the JSON to use in the Karabiner config. Below is the config for Dvorak modified for use with Goku:
;; Your vendor_id and product_id may be different, confirm it under the Devices
;; tab in Karabiner-Elements Preferences.
:devices {
:YubiKey [{:vendor_id 4176 :product_id 1031}]
}
:main [
{:des "YubiKey Dvorak to QWERTY"
:rules [:YubiKey
[:b :n]
[:c :i]
[:close_bracket :equal_sign]
[:comma :w]
[:d :h]
[:period :e]
[:e :d]
[:equal_sign :close_bracket]
[:f :y]
[:g :u]
[:h :j]
[:i :g]
[:j :c]
[:k :v]
[:l :p]
[:hyphen :quote]
[:n :l]
[:o :s]
[:open_bracket :hyphen]
[:p :r]
[:q :x]
[:quote :q]
[:r :o]
[:s :semicolon]
[:semicolon :z]
[:slash :open_bracket]
[:t :k]
[:u :f]
[:v :period]
[:w :comma]
[:x :b]
[:y :t]
]}
Recompile your karabiner config with the goku
command and you should be good to go. You may need to update the key assigned to your accounts. You can change between QWERTY and Dvorak input with the YubiKey by checking the box next to the YubiKey in the Karabiner-Elements Preferences under the Devices tab if you need to authenticate with an old Dvorak key before changing it to a QWERTY key.