diff --git a/content/about.md b/content/about.md index 6ebbfb0..fb7598c 100644 --- a/content/about.md +++ b/content/about.md @@ -9,6 +9,14 @@ This is a static site generated using [Hugo](https://gohugo.io/). There's a publ [here](https://github.com/alejandro-angulo/alejandr0angul0.dev). Nothing fancy going on. I'm planning on using this site as a sort of personal documentation. Hopefully what I write here will be useful to whoever stumbles upon it. +For you vim fans, this site supports scrolling vertically with vim bindings (as long as you allow this site to run javascript). As +of now the following are supported: + +- `j` (scrolls down) +- `k` (scrolls up) +- `gg` (scrolls to top) +- `G` (scrolls to bottom) + ## Me I'm Alejandro Angulo, a code monkey living in the Los Angeles area. When I'm not ~~introducting bugs~~ writing beautiful, @@ -18,4 +26,3 @@ I like to pass the time binge watching TV shows on Hulu/Netflix and starting (bu ### Contact I can be reached at `iam@`. - diff --git a/themes/alejandro-angulo/layouts/partials/footer.html b/themes/alejandro-angulo/layouts/partials/footer.html index e69de29..0380a4c 100644 --- a/themes/alejandro-angulo/layouts/partials/footer.html +++ b/themes/alejandro-angulo/layouts/partials/footer.html @@ -0,0 +1 @@ + diff --git a/themes/alejandro-angulo/static/js/keynav.js b/themes/alejandro-angulo/static/js/keynav.js new file mode 100644 index 0000000..dea7ba7 --- /dev/null +++ b/themes/alejandro-angulo/static/js/keynav.js @@ -0,0 +1,45 @@ +/* + * Adds vim-like keyboard navigation. + * + * Currently supports: + * - j (scroll down) + * - k (scroll up) + * - gg (scroll to top) + * - G (scroll to bottom) + */ + +const scroll_vertical = 100; +const scroll_behavior = "smooth"; +let last_key = null; + +document.addEventListener("keydown", (e) => { + console.log(e); + + let scroll_factor = 1; + + if (e.key === "k") { + scroll_factor *= -1; + } + + switch (e.key) { + case "j": + case "k": + window.scrollBy({ + top: scroll_factor * scroll_vertical, + behavior: scroll_behavior, + }); + break; + + case "g": + if (last_key === "g") { + window.scroll(0, 0); + } + break; + + case "G": + window.scroll(0, document.body.scrollHeight); + break; + } + + last_key = e.key; +});