feat: test
This commit is contained in:
@@ -1,9 +1,36 @@
|
|||||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useWindowEvent } from "@mantine/hooks";
|
||||||
|
import { Textarea } from "@mantine/core";
|
||||||
|
|
||||||
export const Route = createLazyFileRoute("/test")({
|
export const Route = createLazyFileRoute("/test")({
|
||||||
component: TestPage,
|
component: TestPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
function TestPage() {
|
function TestPage() {
|
||||||
return <></>;
|
const [lines, setLines] = useState<string[]>([]);
|
||||||
|
function deserializeKeyboardEvent(eventData:KeyboardEvent): object {
|
||||||
|
return {
|
||||||
|
key: eventData.key,
|
||||||
|
code: eventData.code,
|
||||||
|
location: eventData.location,
|
||||||
|
ctrlKey: eventData.ctrlKey,
|
||||||
|
shiftKey: eventData.shiftKey,
|
||||||
|
altKey: eventData.altKey,
|
||||||
|
metaKey: eventData.metaKey,
|
||||||
|
repeat: eventData.repeat,
|
||||||
|
isComposing: eventData.isComposing,
|
||||||
|
charCode: eventData.charCode,
|
||||||
|
keyCode: eventData.keyCode,
|
||||||
|
which: eventData.which,
|
||||||
|
bubbles: eventData.bubbles,
|
||||||
|
cancelable: eventData.cancelable,
|
||||||
|
composed: eventData.composed,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
useWindowEvent("keydown", event => {
|
||||||
|
setLines(prev => [...prev, JSON.stringify(deserializeKeyboardEvent(event))]);
|
||||||
|
});
|
||||||
|
console.log(lines)
|
||||||
|
return <Textarea autosize value={lines.join("\n")} />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user