Last active
May 7, 2018 10:03
-
-
Save fgnass/3f1a8845163aacba5f9a851a1d5d190d to your computer and use it in GitHub Desktop.
Use arrow keys to scroll through the input history in Amazon's Alexa simulator
This file contains 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 characters
(function() { | |
let i = 0; | |
const el = document.querySelector('.askt-utterance__input'); | |
el.addEventListener('keyup', function(ev) { | |
const req = document.querySelectorAll('.askt-dialog__message--request'); | |
if (ev.key == 'ArrowUp') i = i >= req.length - 1 ? 0 : i + 1; | |
else if (ev.key == 'ArrowDown') i = i > 0 ? i - 1 : req.length - 1; | |
else return; | |
el.value = ''; | |
document.execCommand('insertText', false, req[i].innerText); | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment