TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
An easy way to receive notifications on iPhone simulator when physical keyboard is pressed. Useful for debugging or playing with the interface and application logic directly from the keyboard.
Based on the idea from: https://github.com/cloudkite/Commando
JRSwizzle - https://github.com/rentzsch/jrswizzle
Include all the files inside the directory PhysicalKeyboardNotifications
Add to your .pch
the file PhysicalKeyboardNotifications.h
Add as observer for PKNKeyUpNotification or PKNKeyDownNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardKeyDownNotification:) name:PKNKeyDownNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardKeyDownNotification:) name:PKNKeyUpNotification object:nil];
- (void)onKeyboardKeyUpNotification:(NSNotification*)notification { PKNKeyInputCode keyCode = [notification.userInfo[PKNKeyInputCodeNotificationUserInfoKey] shortValue]; NSString *keyChar = notification.userInfo[PKNKeyInputCharNotificationUserInfoKey]; NSLog(@"KEY UP: %hd, CHAR: %@", keyCode, keyChar); }
PKNKeyInputCharNotificationUserInfoKey
but don't panic there are several macro defined values to compare their keyCodes in PkNDefines.h