Skip to content

Commit

Permalink
refactor(hotkey): attempt to make code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Mar 30, 2021
1 parent 035d8da commit 8b4777a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
//
// Returns key character String or null.
export default function hotkey(event: KeyboardEvent): string {
const elideShift = event.code.startsWith('Key') && event.shiftKey
return `${event.ctrlKey ? 'Control+' : ''}${event.altKey ? 'Alt+' : ''}${event.metaKey ? 'Meta+' : ''}${
event.shiftKey && !event.code.startsWith('Key') ? 'Shift+' : ''
}${event.key}`
event.shiftKey && !elideShift ? 'Shift+' : ''
}${elideShift ? event.key.toUpperCase() : event.key}`
}

0 comments on commit 8b4777a

Please sign in to comment.