@@ -17,7 +17,7 @@ import { areSortedArraysEqual } from "../utils/arrays";
1717import { LayoutObject } from "@monkeytype/schemas/layouts" ;
1818import { animate } from "animejs" ;
1919
20- export const keyDataDelimiter = "~~ " ;
20+ export const keyDataDelimiter = "\uE000 " ;
2121
2222const stenoKeys : LayoutObject = {
2323 keymapShowTopRow : true ,
@@ -58,27 +58,30 @@ const stenoKeys: LayoutObject = {
5858 } ,
5959} ;
6060
61+ function findKeyElements ( char : string ) : JQuery {
62+ if ( char === " " ) {
63+ return $ ( "#keymap .keySpace" ) ;
64+ }
65+
66+ if ( char === '"' ) {
67+ return $ ( `#keymap .keymapKey[data-key*='${ char } ']` ) ;
68+ }
69+
70+ return $ ( `#keymap .keymapKey[data-key*="${ char } "]` ) ;
71+ }
72+
6173function highlightKey ( currentKey : string ) : void {
6274 if ( Config . mode === "zen" ) return ;
6375 if ( currentKey === "" ) currentKey = " " ;
6476 try {
6577 $ ( ".activeKey" ) . removeClass ( "activeKey" ) ;
6678
67- let highlightKey ;
6879 if ( Config . language . startsWith ( "korean" ) ) {
6980 currentKey = Hangul . disassemble ( currentKey ) [ 0 ] ?? currentKey ;
7081 }
71- if ( currentKey === " " ) {
72- highlightKey = "#keymap .keySpace" ;
73- } else if ( currentKey === '"' ) {
74- highlightKey = `#keymap .keymapKey[data-key*='${ currentKey } ']` ;
75- } else {
76- highlightKey = `#keymap .keymapKey[data-key*="${ currentKey } "]` ;
77- }
78-
79- // console.log("highlighting", highlightKey);
8082
81- $ ( highlightKey ) . addClass ( "activeKey" ) ;
83+ const $target = findKeyElements ( currentKey ) ;
84+ $target . addClass ( "activeKey" ) ;
8285 } catch ( e ) {
8386 if ( e instanceof Error ) {
8487 console . log ( "could not update highlighted keymap key: " + e . message ) ;
@@ -88,14 +91,11 @@ function highlightKey(currentKey: string): void {
8891
8992async function flashKey ( key : string , correct ?: boolean ) : Promise < void > {
9093 if ( key === undefined ) return ;
91- //console.log("key", key);
92- if ( key === " " ) {
93- key = "#keymap .keySpace" ;
94- } else if ( key === '"' ) {
95- key = `#keymap .keymapKey[data-key*='${ key } ']` ;
96- } else {
97- key = `#keymap .keymapKey[data-key*="${ key } "]` ;
98- }
94+
95+ const $target = findKeyElements ( key ) ;
96+
97+ const elements = $target . toArray ( ) ;
98+ if ( elements . length === 0 ) return ;
9999
100100 const themecolors = await ThemeColors . getAll ( ) ;
101101
@@ -120,7 +120,7 @@ async function flashKey(key: string, correct?: boolean): Promise<void> {
120120 } ;
121121 }
122122
123- animate ( key , {
123+ animate ( elements , {
124124 color : [ startingStyle . color , themecolors . sub ] ,
125125 backgroundColor : [ startingStyle . backgroundColor , themecolors . subAlt ] ,
126126 borderColor : [ startingStyle . borderColor , themecolors . sub ] ,
0 commit comments