feat: add arrow key navigation to calculator sample
This commit is contained in:
@@ -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