0

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

Andrew
  • 15,357
  • 6
  • 66
  • 101

1 Answers1

0

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";
   }
}
Eliza Wilson
  • 1,031
  • 1
  • 13
  • 38
  • Okay because what I had done was create button in the .xib file and put them into the order of a QWERTY keyboard then give them their corresponding letter. Then i put all the characters into this array: @property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *keysArray; After that in the ViewController.m I added this code so that when the keys are pressed theyll input their character title: - (void)pressKey:(UIButton *)key{ [self.textDocumentProxy insertText:[key currentTitle]]; } – Jalal Jabarkhiel Aug 24 '14 at 03:09
  • How would I use the image method you mentioned? I remember seeing it before but I just don't know how'd I would go about it. Thank you. – Jalal Jabarkhiel Aug 24 '14 at 03:10
  • Why not return [@"a" uppercaseString]; – Albert Renshaw Aug 28 '14 at 20:47
  • Can you put a solution in swift as well please? – crost Oct 27 '20 at 18:52
  • @crost Someone else would be welcome to write an additional answer! I haven't coded in like six years haha. – Eliza Wilson Oct 28 '20 at 00:28