import { useCallback, useEffect } from "react"; import { useSettingsStore } from "@/hooks/stores"; import { useJsonRpc } from "@/hooks/useJsonRpc"; import notifications from "@/notifications"; import { SettingsPageHeader } from "@components/SettingsPageheader"; import { layouts } from "@/keyboardLayouts"; import { SelectMenuBasic } from "../components/SelectMenuBasic"; import { SettingsItem } from "./devices.$id.settings"; export default function SettingsKeyboardRoute() { const keyboardLayout = useSettingsStore(state => state.keyboardLayout); const setKeyboardLayout = useSettingsStore( state => state.setKeyboardLayout, ); const layoutOptions = Object.entries(layouts).map(([code, language]) => { return { value: code, label: language } }) const [send] = useJsonRpc(); useEffect(() => { send("getKeyboardLayout", {}, resp => { if ("error" in resp) return; setKeyboardLayout(resp.result as string); }); }, [send, setKeyboardLayout]); const onKeyboardLayoutChange = useCallback( (e: React.ChangeEvent) => { const layout = e.target.value; send("setKeyboardLayout", { layout }, resp => { if ("error" in resp) { notifications.error( `Failed to set keyboard layout: ${resp.error.data || "Unknown error"}`, ); } notifications.success("Keyboard layout set successfully"); setKeyboardLayout(layout); }); }, [send, setKeyboardLayout], ); return (

Pasting text sends individual key strokes to the target device. The keyboard layout determines which key codes are being sent. Ensure that the keyboard layout in JetKVM matches the settings in the operating system.

); }