/// namespace com.keyman.osk { let Codes = com.keyman.text.Codes; export class OSKBaseKey extends OSKKey { private capLabel: HTMLDivElement; public readonly row: OSKRow; constructor(spec: OSKKeySpec, layer: string, row: OSKRow) { super(spec, layer); this.row = row; } getId(): string { // Define each key element id by layer id and key id (duplicate possible for SHIFT - does it matter?) return this.spec.elementID; } getCoreId(): string { return this.spec.coreID; } getBaseId(): string { return this.spec.baseKeyID; } // Produces a small reference label for the corresponding physical key on a US keyboard. private generateKeyCapLabel(): HTMLDivElement { // Create the default key cap labels (letter keys, etc.) var x = Codes.keyCodes[this.spec.baseKeyID]; switch(x) { // Converts the keyman key id code for common symbol keys into its representative ASCII code. // K_COLON -> K_BKQUOTE case 186: x=59; break; case 187: x=61; break; case 188: x=44; break; case 189: x=45; break; case 190: x=46; break; case 191: x=47; break; case 192: x=96; break; // K_LBRKT -> K_QUOTE case 219: x=91; break; case 220: x=92; break; case 221: x=93; break; case 222: x=39; break; default: // No other symbol character represents a base key on the standard QWERTY English layout. if(x < 48 || x > 90) { x=0; } } let q = document.createElement('div'); q.className='kmw-key-label'; if(x > 0) { q.innerText=String.fromCharCode(x); } else { // Keyman-only virtual keys have no corresponding physical key. // So, no text for the key-cap. } return q; } private processSubkeys(btn: KeyElement, vkbd: VisualKeyboard) { // Add reference to subkey array if defined var bsn: number, bsk=btn['subKeys'] = this.spec['sk']; // Transform any special keys into their PUA representations. for(bsn=0; bsn