Search code examples
iosios8shiftios-app-extensioncustom-keyboard

How to add a shift key to an iOS 8 Custom Keyboard


Right now I have created a basic prototype custom keyboard, however, I do not know how to make a shift key that would capitalize the letters. Right now the letters are all lowercase. Also I wrote this in Objective-C not Swift, but a swift based solution is welcome as well! :) Thank you


Solution

  • Make a key that toggles between whatever images you are using for it. When the key is toggled to shifted, store that in a boolean property.

    Then, use this code for each key press:

    - (NSString *)stringForAKeyPress:(id)sender {
       if (self.shifted) {
           return @"A";
       } else {
           return @"a";
       }
    }