That's excellent. Thank you. I was able to get the whole keyboard to work
with Alt- and Alt-Shift-, at least the intersection of the set of glyphs from
the prettiest APL keyboard google could find and the list of Unicode points
from the wikipedia page. I'll have to do more work for some weird ones
like Quad+Equal or Circle+Diaeresis.
But I got all these:
⍺⊥∩⌊ε_∇∆⍳∘'⎕∣⊤○⋆?⍴~↓∪⍵⊃↑⊂⋄¨‾<≤=≥>≠∨∧×÷←→⊢⍎⍕⍝⍀⌿
ΑΒΓΔ⍷ΖΗΘ⍸ΚΛ⌷ΝΞΟΠΡΣΤΥΦΧΨΩΪΫ ⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⌹⍞ ⊣≡ ,⍙:
With this:
<html><!-- apl62.html -->
<head>
<meta charset="utf-8" />
<style> </style>
</head>
<body>
<div>
<span class='log'></span>
</div>
</body>
<script>
function key( code ){
const keyboard = {
Backquote:'`',Digit1:'1',Digit2:'2',Digit3:'3',
Digit4:'4',Digit5:'5',Digit6:'6',
Digit7:'7',Digit8:'8',Digit9:'9', Digit0:'0',Minus:'-', Equal:'=',
KeyQ:'q',KeyW:'w',KeyE:'e',KeyR:'r',KeyT:'t',KeyY:'y',KeyU:'u',KeyI:'i',KeyO:'o',KeyP:'p',
BracketLeft:'[', BracketRight:']',Backslash:'\\',
KeyA:'a',KeyS:'s',KeyD:'d',KeyF:'f',KeyG:'g',KeyH:'h',KeyJ:'j',KeyK:'k',KeyL: 'l',
Semicolon:';',Quote:'\'',
KeyZ:'z',KeyX:'x',KeyC:'c',KeyV:'v',KeyB:'b',KeyN:'n',KeyM:'m',
Comma:',',Period:'.',Slash:'/',
Space:' ',Enter:'\r',Backspace:'\b',Escape:'\u001B'
};
if( keyboard.hasOwnProperty( code ) ) code = keyboard[ code ];
return code;
}
function modified( code, event ){
const alphabets = [
"abcdef" + "ghijklmnop" + "qrstuvwxyz" + "`1234567890" + "-=,./;\'[]\\",
"ABCDEF" + "GHIJKLMNOP" + "QRSTUVWXYZ" + "~!@#$%^&*()" + "_+<>?:\"{}|",
"\u237A\u22A5\u2229\u230A\u03B5_" +
"\u2207\u2206\u2373\u2218\'\u2395\u2223\u22A4\u25CB\u22C6" +
"?\u2374\u2308~\u2193\u222A\u2375\u2283\u2191\u2282" +
"\u22C4\u00A8\u203E<\u2264=\u2265>\u2260\u2228\u2227\u00D7\u00F7" +
"\u235D\u2340\u233F\u234E\u2355\u2190\u2192\u22A2",
"\u0391\u0392\u0393\u0394\u2377\u0396" +
"\u0397\u0398\u2378\u039A\u039B\u2337\u039D\u039E\u039F\u03A0" +
"\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03AA\u03AB" +
" \u2336\u236B\u2352\u234B\u233D\u2349\u2296\u235F\u2371\u2372" +
"!\u2339,\u2359:\u2261 \u235E \u22A3",
];
//console.log( code );
const i = alphabets[0].indexOf( code );
const a = (event.shiftKey?1:0) + (event.altKey?2:0);
if( i != -1 ){
code = String.fromCharCode( alphabets[a].charCodeAt( i ) );
}
return [ i != -1 && a < alphabets.length, code ];
}
const log = document.querySelector( '.log' );
document.body.focus();
document.addEventListener( 'keydown', function (event){
var [ b, k ] = modified( key( event.code ), event );
if( b ){
event.preventDefault();
}
return false;
}, true);
document.addEventListener( 'keyup', function (event){
var [ b, k ] = modified( key( event.code ), event );
if( b ){
event.preventDefault();
log.textContent += k;
}
return false;
}, true);