iosobjective-cuikeycommand

How to handle uppercase and lowercase characters when using UIKeyCommand


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?


Solution

  • 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