Characters such as !@#$%^&*()_+
etc. should be handled properly by onKeyDown
. To handle uppercase letters, check to see if the shift-modifier is active:
function onKeyDown(event) {
if (event.key == 'shift' || event.key == 'command' || event.key == 'option' || event.key == 'caps-lock' || event.key == 'control') return;
if (event.modifiers.shift || event.modifiers.capsLock) {
console.log('The ' + event.key.toUpperCase() + ' key was pressed!');
}
else console.log('The ' + event.key + ' key was pressed!');
}