mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-08 01:00:16 +00:00
feat: fire click event on enter for submit buttons
This commit is contained in:
parent
d74a66832f
commit
c466bc5fab
1 changed files with 12 additions and 0 deletions
|
|
@ -1,9 +1,21 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
export let value: string;
|
export let value: string;
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
dispatch('click');
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input on:click type="submit" {value} />
|
<input on:click type="submit" {value} />
|
||||||
|
|
||||||
|
<svelte:window on:keydown={handleKeyDown} />
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
input {
|
input {
|
||||||
@apply bg-sspsBlue hover:bg-sspsBlueDark
|
@apply bg-sspsBlue hover:bg-sspsBlueDark
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue