Currently, I have 9 different functions which has to triggered by single button when onclick and keyboard numpad (1 to 9).
Edit: Solution by Sode- v2
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button type="button" id="b41" onclick="test_ks(event)">Shape Anchor Point</button>
<script>
const pressedButtons = {};
window.onkeydown = (e) => (pressedButtons[e.which] = true);
window.onkeyup = (e) => (pressedButtons[e.which] = false);
function test_ks(event) {
if (pressedButtons[97]) {
alert('numpad 1');
} else if (pressedButtons[98]) {
alert('numpad 2');
}
}
</script>
</body>
</html>
Tried this at https://manjunath7472.w3spaces.com/saved-from-Tryit-2021-11-06.html
Issue 1.After clicking numberpad 1, numberpad 2 doesn't work & After clicking numpad2, numpad1 works but after that numpad 2 doesn't work.
2.After initial click on anyone, from second time, with just mouse click(without pressing keyboard numpad) it triggers the alert.
3.After first clcik with keypress, it doesn't consider keyboard press and alert is triggered by mouse click only.