all repos — kōi @ 6552cde48bf0f293b876864af2aff29c013e24f5

Minimalist task manager

src/routes/(auth)/NewTask.svelte (view raw)

 1<script lang="ts">
 2	import { db } from '$lib/db';
 3
 4	const onKeyDown = (e: KeyboardEvent) => {
 5		const element = e.target as HTMLInputElement;
 6		const inputValue = element?.value;
 7		const enterKeys = ['Enter', 'NumpadEnter'];
 8		if (inputValue && enterKeys.includes(e.code)) {
 9			db.tasks.add({ content: inputValue });
10			element.value = '';
11		}
12	};
13</script>
14
15<input
16	class="input input-bordered w-full"
17	type="text"
18	placeholder="Ajouter une tâche"
19	onkeydown={onKeyDown}
20/>