From 38088a39e311668f69a2529a7f5553b54c8ff92d Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Mon, 20 Nov 2023 22:14:25 +0530 Subject: [PATCH] (feat): added keybinding-config.js to handle keyboard shotcuts --- htdocs/assets/js/keybinding-config.js | 31 +++++++++++++++++++++++++++ htdocs/blog.php | 1 + htdocs/contact.php | 1 + htdocs/home.php | 1 + htdocs/projects.php | 1 + 5 files changed, 35 insertions(+) create mode 100644 htdocs/assets/js/keybinding-config.js diff --git a/htdocs/assets/js/keybinding-config.js b/htdocs/assets/js/keybinding-config.js new file mode 100644 index 0000000..9196893 --- /dev/null +++ b/htdocs/assets/js/keybinding-config.js @@ -0,0 +1,31 @@ +let pressedKeys = {}; + +document.addEventListener('keydown', function(event) { + pressedKeys[event.key] = true; + + if (pressedKeys['n'] && pressedKeys['h']) { + window.location.href = basePath; + } + else if (pressedKeys['n'] && pressedKeys['p']) { + window.location.href = basePath + "/projects"; + } + else if (pressedKeys['n'] && pressedKeys['b']) { + window.location.href = basePath + "/blog"; + } + else if (pressedKeys['n'] && pressedKeys['c']) { + window.location.href = basePath + "/contact"; + } + else if (pressedKeys['q'] && pressedKeys['e']) { + window.location.href = "mailto:hey@neosubhamoy.dev"; + } + else if (pressedKeys['q'] && pressedKeys['m']) { + window.location.href = "#"; + } + else if (pressedKeys['q'] && pressedKeys['s']) { + window.location.href = "#"; + } +}); + +document.addEventListener('keyup', function(event) { + pressedKeys[event.key] = false; +}); \ No newline at end of file diff --git a/htdocs/blog.php b/htdocs/blog.php index 2f033dd..eff4bf6 100644 --- a/htdocs/blog.php +++ b/htdocs/blog.php @@ -26,5 +26,6 @@ require 'core/query_functions.php'; + \ No newline at end of file diff --git a/htdocs/contact.php b/htdocs/contact.php index a67b0dc..9c1cc04 100644 --- a/htdocs/contact.php +++ b/htdocs/contact.php @@ -23,5 +23,6 @@ require 'core/query_functions.php'; + \ No newline at end of file diff --git a/htdocs/home.php b/htdocs/home.php index 63b9c96..03a02d3 100644 --- a/htdocs/home.php +++ b/htdocs/home.php @@ -216,6 +216,7 @@ require 'core/query_functions.php'; + + \ No newline at end of file