Mapping various keyboard layout sources and key codes in macOS. (e.g.: QWERTY, Dvorak)
Only the ANSI-standard US keyboard is defined for the key code defined in Carbon.framework. Therefore, we can obtain only the key code of the QWERTY keyboard layout. (e.g.:
In layout other than QWERTY, (e.g. Dvorak) the virtual key code is different.
|Keyboard Layout||Key||Key Code|
This library is created with the purpose of mapping the key code of the input sources and making it possible to obtain the correct key code in various keyboard layouts.
Get the key code of the current input source.
let keyCode = Sauce.shared.keyCode(for: .v)
Key of the current input source.
let key = Sauce.shared.key(for: keyCode)
Get the character of the current input source.
let character = Sauce.shared.character(for: keyCode, carbonModifiers: shiftKey) let character = Sauce.shared.character(for: keyCode, cocoaModifiers: [.shift])
SauceEnabledKeyboardInputSourcesChanged is the same as
kTISNotifyEnabledKeyboardInputSourcesChanged in Carbon.framework
SauceSelectedKeyboardInputSourceChanged is different from
kTISNotifySelectedKeyboardInputSourceChanged and is notified only when the input source id has changed.
Since it is filtered and notified, please do not use it for the same purpose as normal
By using this Notification, can detect when the setting changes with the same keyboard layout, when the input source changes from QWERTY to Dvorak, and so on.