File size: 373 Bytes
3a1d71c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export const getShortcutStrFromEvent = (e: KeyboardEvent) => {
  const keys = [] as string[]
  if (e.shiftKey) {
    keys.push('Shift')
  }
  if (e.ctrlKey) {
    keys.push('Ctrl')
  }
  if (e.metaKey) {
    keys.push('Cmd')
  }
  if (e.code.startsWith('Key') || e.code.startsWith('Digit')) {
    keys.push(e.code)
  }
  const keysStr = keys.join(' + ')
  return keysStr
}