Use -[NSMenuItem setKeyEquivalent:]and assign it the NSStringcharacter you want to use. NSMenuItemwill handle the translation @" "in Spacefor you etc.
Delete key (aka "Backspace". This is the usual delete button on the keyboard):
[myMenuItem setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x08]];
Direct delete key ("del" key):
[myMenuItem setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x7f]];
space:
[myMenuItem setKeyEquivalent:@" "];
Tab:
[myMenuItem setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x09]];
source
share