mirror of
https://github.com/neosubhamoy/neosubhamoy-portfolio.git
synced 2025-12-20 03:29:35 +05:30
(refactor): improved keyboard shotcut keyevent detection
This commit is contained in:
@@ -123,7 +123,7 @@ mobileSearchBtn.addEventListener("click", function () {
|
|||||||
|
|
||||||
// when ALT + K shortcut key is pressed
|
// when ALT + K shortcut key is pressed
|
||||||
document.addEventListener("keydown", function(event) {
|
document.addEventListener("keydown", function(event) {
|
||||||
if (event.altKey && event.key === "k") {
|
if ((event.altKey && event.key === "k") || (event.altKey && event.key === "K")) {
|
||||||
if(!isShareActive) {
|
if(!isShareActive) {
|
||||||
activate_search();
|
activate_search();
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ mobileShareCloseBtn.addEventListener("click", function () {
|
|||||||
|
|
||||||
// when ALT + L shortcut key is pressed
|
// when ALT + L shortcut key is pressed
|
||||||
document.addEventListener("keydown", function(event) {
|
document.addEventListener("keydown", function(event) {
|
||||||
if (event.altKey && event.key === "l") {
|
if ((event.altKey && event.key === "l") || (event.altKey && event.key === "L")) {
|
||||||
if(!isSearchActive) {
|
if(!isSearchActive) {
|
||||||
activate_share();
|
activate_share();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,25 +28,25 @@ async function redirectToURL(item) {
|
|||||||
document.addEventListener('keydown', function(event) {
|
document.addEventListener('keydown', function(event) {
|
||||||
pressedKeys[event.key] = true;
|
pressedKeys[event.key] = true;
|
||||||
|
|
||||||
if (pressedKeys['n'] && pressedKeys['h']) {
|
if ((pressedKeys['n'] && pressedKeys['h']) || (pressedKeys['N'] && pressedKeys['H'])) {
|
||||||
window.location.href = basePath;
|
window.location.href = basePath;
|
||||||
}
|
}
|
||||||
else if (pressedKeys['n'] && pressedKeys['p']) {
|
else if ((pressedKeys['n'] && pressedKeys['p']) || (pressedKeys['N'] && pressedKeys['P'])) {
|
||||||
window.location.href = basePath + "/projects";
|
window.location.href = basePath + "/projects";
|
||||||
}
|
}
|
||||||
else if (pressedKeys['n'] && pressedKeys['b']) {
|
else if ((pressedKeys['n'] && pressedKeys['b']) || (pressedKeys['N'] && pressedKeys['B'])) {
|
||||||
window.location.href = basePath + "/blog";
|
window.location.href = basePath + "/blog";
|
||||||
}
|
}
|
||||||
else if (pressedKeys['n'] && pressedKeys['c']) {
|
else if ((pressedKeys['n'] && pressedKeys['c']) || (pressedKeys['N'] && pressedKeys['C'])) {
|
||||||
window.location.href = basePath + "/contact";
|
window.location.href = basePath + "/contact";
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['e']) {
|
else if ((pressedKeys['q'] && pressedKeys['e']) || (pressedKeys['Q'] && pressedKeys['E'])) {
|
||||||
redirectToURL('email');
|
redirectToURL('email');
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['m']) {
|
else if ((pressedKeys['q'] && pressedKeys['m']) || (pressedKeys['Q'] && pressedKeys['M'])) {
|
||||||
redirectToURL('chat');
|
redirectToURL('chat');
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['s']) {
|
else if ((pressedKeys['q'] && pressedKeys['s']) || (pressedKeys['Q'] && pressedKeys['S'])) {
|
||||||
redirectToURL('sources');
|
redirectToURL('sources');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user