Latest 0.1
Homepage https://github.com/brovador/PhysicalKeyboardNotifications
License MIT
Platforms ios 5.0, requires ARC
Dependencies JRSwizzle
Authors

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

Installation

Using Cocoapods, just add to your Podfile:

pod 'PhysicalKeyboardNotifications'

Dependencies

JRSwizzle – https://github.com/rentzsch/jrswizzle

Usage

  • Install using Cocapods or adding the files directly into your proyect
  • 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];  
    
  • In the notification observer method recover from userInfo dictionary the pressed keyValue or a NSString representing the char
- (void)onKeyboardKeyDownNotification:(NSNotification*)notification
{
    PKNKeyInputCode keyCode = [notification.userInfo[PKNKeyInputCodeNotificationUserInfoKey] shortValue];
    NSString *keyChar = notification.userInfo[PKNKeyInputCharNotificationUserInfoKey];
    NSLog(@"KEY UP: %hd, CHAR: %@", keyCode, keyChar);
}
  • Special keys as space, return, delete or arrows will return and empty string in the key PKNKeyInputCharNotificationUserInfoKey
    but don’t panic there are several macro defined values to compare their keyCodes in PkNDefines.h

Latest podspec

{
    "name": "PhysicalKeyboardNotifications",
    "version": "0.1",
    "summary": "Posting notifications on iPhone simulator when physical keyboard is pressed. Useful for debugging",
    "homepage": "https://github.com/brovador/PhysicalKeyboardNotifications",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "brovador": "[email protected]"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/brovador/PhysicalKeyboardNotifications.git",
        "tag": "v0.1"
    },
    "source_files": "PhysicalKeyboardNotifications",
    "requires_arc": true,
    "dependencies": {
        "JRSwizzle": []
    }
}

Pin It on Pinterest

Share This