Skip to content

Instantly share code, notes, and snippets.

@razzius
Created April 13, 2020 01:46
Show Gist options
  • Save razzius/d2a52d478d868a188607042b756e037c to your computer and use it in GitHub Desktop.
Save razzius/d2a52d478d868a188607042b756e037c to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script>
function parseKeyname(keyname) {
const parts = keyname.toLowerCase().split('-')
const modifiers = parts.slice(0, -1)
const key = parts[parts.length - 1]
return {
meta: modifiers.includes('m'),
control: modifiers.includes('c'),
super: modifiers.includes('s'),
key: key,
}
}
const keybindings = {
'M-RET': 'c-s-s',
}
function keybindingName({ meta, control, super, key }) {
// order: C-M-S-key
parts = [control, meta, super]
}
// function rebindKey(from, to) {}
document.onkeydown = (e) => {
console.log('keydown')
console.log(e)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment