feat: add arrow key navigation to calculator sample
This commit is contained in:
1 parent
c47c46ad64
commit
62221a9baa
1 file changed
+11
@@ -316,6 +316,17 @@ function handleKeyboard(event) {
|
|||||||
'%': 'mod',
|
'%': 'mod',
|
||||||
'^': 'pow',
|
'^': 'pow',
|
||||||
};
|
};
|
||||||
|
const arrowMap = {
|
||||||
|
ArrowUp: upButton,
|
||||||
|
ArrowDown: downButton,
|
||||||
|
ArrowLeft: leftButton,
|
||||||
|
ArrowRight: rightButton,
|
||||||
|
};
|
||||||
|
if (arrowMap[key]) {
|
||||||
|
event.preventDefault();
|
||||||
|
arrowMap[key].click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (map[key]) {
|
if (map[key]) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
execute(map[key]);
|
execute(map[key]);
|
||||||
|
|||||||
Reference in new issue
Block a user