git clone [email protected]:lukaszpolowczyk/focus-button.git
cd focus-button
npm run dev
Open url: [http://localhost:3000/1]
Tab key
on the keyboardRight Arrow
on the keyboardQuestion: How do I keep focus without using element.focus()
or anything like that?
GIF with this:
The code looks like this:
<!-- src/routers/[slug].svelte -->
<svelte:head><title>Lost focus - Sveltekit Routers</title></svelte:head>
<script>
import { page } from '$app/stores';
</script>
<br>
page {$page.params.slug}
 
<!-- src/routers/$layout.svelte -->
<script>
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import Keydown from "svelte-keydown";
</script>
<Keydown on:ArrowRight={() => goto(`${Number($page.params.slug)+1}`) } />
<button on:click={()=>goto(`${Number($page.params.slug)+1}`)}>goto({Number($page.params.slug)+1})</button>
or press RightArrow
<slot />