0

We are in the process of receiving and processing keyboard input.

Among my source code,

UIKeyCommand *menuKey = [UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%c", 77]
                                                modifierFlags:0
                                                       action:@selector(menuKey:)];

There is this part.

However, if you process it like this, it will only react when it is an uppercase 'M', and it does not respond when it is a lowercase 'm'.

Is there a way to handle UIKeyCommand with all uppercase and lowercase characters?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Nam
  • 163
  • 1
  • 1
  • 8

2 Answers2

1

You can add command for both Upper case Character and lowercase character

Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31
  • UIKeyCommand *menuKeyUpperCase = [UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%c", 77] modifierFlags:UIKeyModifierShift action:@selector(menuKey:)]; Should I add this? Is there no other way without adding? – Nam Nov 17 '17 at 08:38
  • I don't see any other option. – Dattatray Deokar Nov 17 '17 at 09:14
1

The reason is that you only look for 77 which is ASCII code for M. In order to allow m, you need to add 109 as well

Malik
  • 3,763
  • 1
  • 22
  • 35
  • UIKeyCommand *menuKeyUpperCase = [UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%c", 77] modifierFlags:UIKeyModifierShift action:@selector(menuKey:)]; Should I add this? Is there no other way without adding? – Nam Nov 17 '17 at 08:38