Skip to content

Instantly share code, notes, and snippets.

@pkamb
Last active May 3, 2023 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkamb/6128775 to your computer and use it in GitHub Desktop.
Save pkamb/6128775 to your computer and use it in GitHub Desktop.
Get current Mac OS X keyboard layout.
#import <Carbon/Carbon.h>
//Example: "com.apple.keylayout.US" or "com.apple.keylayout.Dvorak"
+ (NSString *)systemKeyboardLayout
{
TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
CFStringRef layoutID = TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
return (NSString *)layoutID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment