feat(nds): improve key input system
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
export type KeyUpCallback = (key: string) => void;
|
||||
import { mapKeyToNDS } from "~/utils/input";
|
||||
|
||||
export type KeyUpCallback = (params: {
|
||||
key: string;
|
||||
ndsButton: string | null;
|
||||
}) => void;
|
||||
|
||||
export const useKeyUp = (callback: KeyUpCallback) => {
|
||||
const handleKeyUp = (event: KeyboardEvent) => {
|
||||
callback(event.key);
|
||||
const ndsButton = mapKeyToNDS(event.key);
|
||||
callback({
|
||||
key: ndsButton ? `NDS_${ndsButton}` : event.key,
|
||||
ndsButton,
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user