diff --git a/src/UI/InputElement/ValidatedInput.svelte b/src/UI/InputElement/ValidatedInput.svelte index eac4c7ffa..1b2c7da61 100644 --- a/src/UI/InputElement/ValidatedInput.svelte +++ b/src/UI/InputElement/ValidatedInput.svelte @@ -51,6 +51,15 @@ } } + + + function onKeyPress(e: KeyboardEvent){ + if(e.key === "Enter"){ + e.stopPropagation() + e.preventDefault() + dispatch("submit") + } + } initValueAndDenom() $: { @@ -126,7 +135,7 @@ let htmlElem: HTMLInputElement | HTMLTextAreaElement - let dispatch = createEventDispatcher<{ selected }>() + let dispatch = createEventDispatcher<{ selected, submit }>() $: { if (htmlElem !== undefined) { htmlElem.onfocus = () => dispatch("selected") @@ -144,6 +153,7 @@ inputmode={validator?.inputmode ?? "text"} placeholder={_placeholder} bind:this={htmlElem} + on:keypress={onKeyPress} /> {:else}