For the past 15 years (or so), I’ve used the autofocus attribute to move cursor focus to a given form input control upon page load. But, as I’ve become more attune to accessibility (a11y) concerns, I’ve become hesitant about stealing focus and potentially disrupting the feedback provided by assistive technologies. That said, I still really want that ease-of-access for myself. As such, I’ve added a custom Alpine.js directive to Big Sexy Poems that will move focus to the first form input when I press the (f) key.

Using keyboard shortcuts to move focus is a common pattern. Sites, such as GitHub, that provide a global search input, will use the (/) key to move focus to the…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help