Skip to content

Commit

Permalink
better keys
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 21, 2023
1 parent 223111c commit d1b315a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions public/squint/js/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,32 @@ let editorElt = document.querySelector('#editor');
let editor = new EditorView({state: state,
parent: editorElt,
extensions: extensions })

let keys = {"ArrowUp": "↑",
"ArrowDown": "↓",
"ArrowRight": "→",
"ArrowLeft": "←",
"Mod": "Ctrl"}

let macKeys = {"Alt": "⌥",
"Shift": "⇧",
"Enter": "⏎",
"Ctrl": "⌃",
"Mod": "⌘"}

let mac;

if (/^(Mac)|(iPhone)|(iPad)|(iPod)$/.test(window.navigator.platform.substring(0,3))) {
mac = true;
Object.assign(keys, macKeys);
}

document.querySelectorAll(".mod,.alt,.ctrl").forEach(node => {
let k = node.innerHTML;
let symbol = keys[k];
if (symbol) {
node.innerHTML = symbol;
}
}

)

0 comments on commit d1b315a

Please sign in to comment.