Last active
July 1, 2022 20:02
-
-
Save nuxodin/72d7141f79a51d08a8914c8c883719f1 to your computer and use it in GitHub Desktop.
Revisions
-
nuxodin revised this gist
Jul 1, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,11 +21,11 @@ addEventListener('keyup', e=>{ word += e.key; } clearTimeout(wordClearTimeout); wordClearTimeout = setTimeout(()=>{ e.target.dispatchEvent(new CustomEvent('u1-key-word', {bubbles: true, detail: word})); // dispatch here? word = ''; }, 800); -
nuxodin revised this gist
Jul 1, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,6 +25,8 @@ addEventListener('keyup', e=>{ clearTimeout(wordClearTimeout); wordClearTimeout = setTimeout(()=>{ // dispatch here? word = ''; }, 800); }); -
nuxodin revised this gist
Jul 1, 2022 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ // better a "WordObserver" that can better handle chanching targets? let word = ''; let wordClearTimeout = null; let wordTarget = null; @@ -29,4 +28,3 @@ addEventListener('keyup', e=>{ word = ''; }, 800); }); -
nuxodin created this gist
Jul 1, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ /* // track words using a delay to clean // better an WordObserver that can better handle chanching targets? let word = ''; let wordClearTimeout = null; let wordTarget = null; addEventListener('keyup', e=>{ const isChar = /^.$/u.test(e.key); // if (wordTarget !== e.target) { // clear if target changes // word = ''; // wordTarget = e.target; // } if (e.key === 'Backspace') { word = word.slice(0, -1); } else if (!isChar) { word = ''; return; } else { word += e.key; } e.target.dispatchEvent(new CustomEvent('u1-key-word', {bubbles: true, detail: word})); clearTimeout(wordClearTimeout); wordClearTimeout = setTimeout(()=>{ word = ''; }, 800); }); */