diff --git a/bun.lockb b/bun.lockb
index ba3ab499..124f71a5 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte
index 28200b13..86c4b8ca 100644
--- a/src/lib/components/lemmy/post/Post.svelte
+++ b/src/lib/components/lemmy/post/Post.svelte
@@ -84,7 +84,7 @@
{
onClick(e)
}}
+ on:keydown={(e) => {
+ // @ts-ignore
+ if (e.key == 'Enter') onClick(e)
+ }}
+ tabindex="0"
style={$$props.style ?? ''}
>
{/if}
diff --git a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte
index ba7679d4..054ab70b 100644
--- a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte
+++ b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte
@@ -38,6 +38,8 @@
import InfiniteScroll from 'svelte-infinite-scroll'
import type { Readable } from 'svelte/motion'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
+ import { postLink } from '../helpers'
+ import { writable } from 'svelte/store'
export let posts: PostView[]
export let community: boolean = false
@@ -177,8 +179,37 @@
await tick()
$virtualizer.measure()
})
+
+ // keyboard handling
+ let selectedIndex = writable(-1)
+
+ function handleKeydown(event: KeyboardEvent) {
+ if (event.key === 'ArrowUp') {
+ event.preventDefault()
+ $selectedIndex = Math.max(0, $selectedIndex - 1)
+ } else if (event.key === 'ArrowDown') {
+ event.preventDefault()
+ $selectedIndex = Math.min(posts.length - 1, $selectedIndex + 1)
+ }
+ }
+
+ onMount(() => {
+ selectedIndex.subscribe(focusItem)
+ })
+
+ function focusItem(index: number) {
+ const el =
+ virtualItemEls.find(
+ (el) => Number(el?.getAttribute('data-index')) == index
+ ) ?? virtualItemEls[1]
+
+ $virtualizer.scrollToIndex(index, { align: 'center', behavior: 'auto' })
+ el?.firstChild?.firstChild?.parentElement?.focus({})
+ }
+
+