From 47ade4583cc9dfdcd2be317e9efec45efe81c9c0 Mon Sep 17 00:00:00 2001 From: Bailey Furrow Date: Thu, 4 Jan 2024 21:51:46 -0500 Subject: [PATCH] added quick index jump --- quick_index_jump.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 quick_index_jump.js diff --git a/quick_index_jump.js b/quick_index_jump.js new file mode 100644 index 0000000..3ed076d --- /dev/null +++ b/quick_index_jump.js @@ -0,0 +1,19 @@ +/* This function will take a function page and allow jumping to certain letters + * by using the letters on the keyboard. */ +function index_jump() { + + + document.addEventListener('keyup', captureKeys); + document.addEventListener('focus', () => { + document.removeEventListener(captureKeys); + }); + document.addEventListener('blur', () => { + document.addEventListener('keyup', captureKeys); + }); + + function captureKeys(e) { + let letter = e.key; + let id = document.querySelector('#' + letter) || document.querySelector('[id*=' + letter + ']'); + id.scrollIntoView(); + } +}