File size: 425 Bytes
0070fce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
  }
  if (e.key ==='Escape') {
    keys.push('Esc')
  }
  const keysStr = keys.join(' + ')
  return keysStr
}