feat(nds): physical dpad
This commit is contained in:
15
app/composables/useKeyUp.ts
Normal file
15
app/composables/useKeyUp.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export type KeyUpCallback = (key: string) => void;
|
||||
|
||||
export const useKeyUp = (callback: KeyUpCallback) => {
|
||||
const handleKeyUp = (event: KeyboardEvent) => {
|
||||
callback(event.key);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener("keyup", handleKeyUp);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("keyup", handleKeyUp);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user