use new registerShortcut() fuction in DeckConfigPage

This commit is contained in:
Damien Elmes 2021-04-23 11:20:12 +10:00
parent 42c466223e
commit 79b62682ab

View file

@ -6,18 +6,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import ConfigSelector from "./ConfigSelector.svelte"; import ConfigSelector from "./ConfigSelector.svelte";
import ConfigEditor from "./ConfigEditor.svelte"; import ConfigEditor from "./ConfigEditor.svelte";
import type { DeckConfigState } from "./lib"; import type { DeckConfigState } from "./lib";
import { primaryModifierForPlatform } from "sveltelib/shortcuts"; import { onMount, onDestroy } from "svelte";
import { registerShortcut } from "lib/shortcuts";
export let state: DeckConfigState; export let state: DeckConfigState;
function onKeyDown(evt: KeyboardEvent): void { onMount(() => {
if ( onDestroy(registerShortcut(() => state.save(false), "Control+Enter"));
evt.code === "Enter" && });
evt.getModifierState(primaryModifierForPlatform())
) {
state.save(false);
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
@ -27,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
</style> </style>
<div on:keydown={onKeyDown}> <div>
<div id="modal"> <div id="modal">
<!-- filled in later--> <!-- filled in later-->
</div> </div>