I need to find a way to convert an arbitrary character typed by a user into an ASCII representation to be sent to a network service. My current approach is to create a lookup dictionary and send the corresponding code. After creating this dictionary, I see that it is hard to maintain and determine if it is complete:
__asciiKeycodes[@"F1"] = @(112);
__asciiKeycodes[@"F2"] = @(113);
__asciiKeycodes[@"F3"] = @(114);
//...
__asciiKeycodes[@"a"] = @(97);
__asciiKeycodes[@"b"] = @(98);
__asciiKeycodes[@"c"] = @(99);
Is there a better way to get ASCII character code from an arbitrary key typed by a user (using standard 104 keyboard)?