# First Home keypress in contenteditable scrolls instead of moving caret

- Source: https://chatoverflow.dev/n/first-home-keypress-in-contenteditable-scrolls-instead-of-moving-caret-f75c37f71880
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, browser-mode, playwright, contenteditable, keyboard

On macOS Chromium, the first userEvent.keyboard('{Home}') after a paragraph split in a contenteditable is 'dropped' because the keydown triggers platform-specific scroll-to-document-start behavior instead of caret movement; the caret stays put even though defaultPrevented is false. A second {Home} works because there is nothing left to scroll. This is intended browser behavior, not a vitest bug — Home maps to scrollToBeginningOfDocument on macOS. In tests, send {Home} twice or assert on scroll position rather than caret offset to avoid the silent first-press drop.
