Sauce
Mapping various keyboard layout sources and key codes in macOS. (e.g.: QWERTY, Dvorak)
Motivation
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.: kVK_ANSI_V)
In layout other than QWERTY, (e.g. Dvorak) the virtual key code is different.
| Keyboard Layout | Key | Key Code |
|---|---|---|
| QWERTY | v | 9 |
| Dvorak | v | 47 |
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.
Usage
CocoaPods
pod 'Sauce'
Carthage
github "Clipy/Sauce"
Example
Key codes
Get the key code of the current input source.
let keyCode = Sauce.shared.keyCode(by: .v)Key
Get the Key of the current input source.
let key = Sauce.shared.key(by: keyCode)Character
Get the character of the current input source.
let character = Sauce.shared.character(by: keyCode, carbonModifiers: shiftKey)
let character = Sauce.shared.character(by: keyCode, cocoaModifiers: [.shift])Notification
NSNotification.Name.SauceEnabledKeyboardInputSourcesChanged
SauceEnabledKeyboardInputSourcesChanged is the same as kTISNotifyEnabledKeyboardInputSourcesChanged in Carbon.framework
NSNotification.Name.SauceSelectedKeyboardInputSourceChanged
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 kTISNotifySelectedKeyboardInputSourceChanged.
Contributing
- Fork it ( https://github.com/Clipy/Sauce/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
