Last active
March 9, 2020 12:55
-
-
Save ferbass/0ddea86e6b2eb5915fabdbfe9f151a5e to your computer and use it in GitHub Desktop.
UIKeyCommand external keyboard keys, extract from https://github.com/kishikawakatsumi/KeyboardShortcuts/blob/master/KeyCommands/ViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray *commands = [[NSMutableArray alloc] init]; | |
NSString *characters = @"`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./"; | |
for (NSInteger i = 0; i < characters.length; i++) { | |
NSString *input = [characters substringWithRange:NSMakeRange(i, 1)]; | |
/* Caps Lock */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierAlphaShift action:@selector(handleCommand:)]]; | |
/* Shift */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierShift action:@selector(handleCommand:)]]; | |
/* Control */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierControl action:@selector(handleCommand:)]]; | |
/* Option */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierAlternate action:@selector(handleCommand:)]]; | |
/* Command */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierCommand action:@selector(handleCommand:)]]; | |
/* Control + Option */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierControl | UIKeyModifierAlternate action:@selector(handleCommand:)]]; | |
/* Control + Command */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierControl | UIKeyModifierCommand action:@selector(handleCommand:)]]; | |
/* Option + Command */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierAlternate | UIKeyModifierCommand action:@selector(handleCommand:)]]; | |
/* Control + Option + Command */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierControl | UIKeyModifierAlternate | UIKeyModifierCommand action:@selector(handleCommand:)]]; | |
/* No modifier */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
} | |
/* Delete */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:@"\b" modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Tab */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Enter */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Up */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Down */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Left */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Right */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; | |
/* Esc */ | |
[commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:kNilOptions action:@selector(handleCommand:)]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample in Objective-c, if you need to use it with swift follow the sample bellow
/* Enter */
UIKeyCommand.init(input: "\r", modifierFlags: [], action: nil)