substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing systems.
20 lines (18 loc) • 450 B
JavaScript
export {default as keys} from './keys'
export function parseKeyEvent(event, onlyModifiers) {
let frags = []
if (event.altKey) {
if (event.code === 'AltRight') {
frags.push('ALTGR')
} else {
frags.push('ALT')
}
}
if (event.ctrlKey) frags.push('CTRL')
if (event.metaKey) frags.push('META')
if (event.shiftKey) frags.push('SHIFT')
if (!onlyModifiers) {
frags.push(event.keyCode)
}
return frags.join('+')
}