# Smooth J/K navigation when using keyboard

**URL:** https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634
**Category:** Theme component
**Tags:** deprecated
**Created:** [February 7, 2019, 12:35pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634 "2019-02-07T12:35:34Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![dan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dan/32/101549_2.png) [@dan](https://meta.discourse.org/u/dan)
#### Post date: [February 7, 2019, 12:35pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/1 "2019-02-07T12:35:34Z")

</div>

> ⚠ This theme component has been deprecated and reimplemented in core.

This theme component is on track to be implemented in core ([PR](https://github.com/discourse/discourse/pull/7084)).

[https://github.com/udan11/discourse-jk-smooth-mooves](https://github.com/udan11/discourse-jk-smooth-mooves)

I amends the behaviour of jk navigation within topics so the viewport scrolls as you hit the keys.

It handles 3 cases:

1. Long posts will scroll to full view before going to next post
2. When you navigate between posts the window will scroll so you have context
3. It toggles to a fast navigation mode when long pressing a navigation key

This is installed on meta and can be used by selecting “Sam’s Simple Theme”

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 7, 2019, 9:14pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/2 "2019-02-07T21:14:50Z")

</div>

This is definitely getting there… however…

- On Chrome it is pretty smooth
- On Firefox it is slightly less smooth
- On Safari it is least smooth

Can you have a look at: [Smooth Scrolling | CSS-Tricks](https://css-tricks.com/snippets/jquery/smooth-scrolling/) and use this trick, from what I can tell it is buttery smooth on Safari.

The scroll within long post is MAGICAL and amazing!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 7, 2019, 9:19pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/3 "2019-02-07T21:19:50Z")

</div>

Another entirely minor issue we want to sort out… head to:

> [@Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045):
>
> [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) is a core Discourse feature that allows you to configure “Single Sign-On (SSO)” to completely outsource all user registration and login from Discourse to another site. Offered to our [pro, business and enterprise hosting customers](https://discourse.org/pricing). information_source (Feb 2021) ‘[Discourse SSO](https://meta.discourse.org/t/13045?silent=true)’ is now ‘[DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)’. If you are running an old version of Discourse, the settings below will be named sso\_... rather than discourse\_connect\_... The Problem Many sites wishing to integrate wit…

Then hit `j` a few times `k` stops working cause it is on first post.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 7, 2019, 9:26pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/4 "2019-02-07T21:26:00Z")

</div>

Another one, (which I guess is proof I am using it 😊)

If you hold `J` down or `K` down some stuff is not getting properly debounce, stuff backs up and gets weird (at least on Safari)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 8, 2019, 6:57am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/5 "2019-02-08T06:57:04Z")

</div>

I don’t feel people who use keyboard nav are looking for videogame style transitions between posts.. the whole point of using the keyboard efficiency, not meaningless (and slow) cosmetic animations.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [February 8, 2019, 1:57pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/6 "2019-02-08T13:57:27Z")

</div>

I don’t want slow cosmetic changes, but something to make the transition less jarring on my eyes. I started using this feature recently and found the jumps to be disorienting especially if they were between long posts. I’d love to see a balance in the middle personally.

---

<div class="post-metadata">

### Author: ![Anatolia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anatolia/32/133777_2.png) [@Anatolia](https://meta.discourse.org/u/Anatolia)
#### Post date: [February 8, 2019, 3:07pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/7 "2019-02-08T15:07:14Z")

</div>

The component shows weird up and down moves if I hold on buttons. I have to click J and K buttons one by one for proper movement. Also that line on the left side of post should disappear after a few seconds and transtition between posts might be more slow, like floating.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 11, 2019, 1:30am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/8 "2019-02-11T01:30:19Z")

</div>

First, I want to mention that this survived a Monday, which is awesome. 😍🤩 This is the **First** time I was able to do my full catch up using keyboard, I do still sometimes reach to my mouse to cut-and-paste and quote and so on.

The basic mechanics of catching up are very close, to summarize here are all the bugs (+ a new one) that we want sorted.

I do feel this may become a core feature, cause with this component J K turned from unusable for **Sam** to indispensable to **Sam** , which is a big jump in my hierarchy of needs.

Bugs to fix:

- Up navigation with K does not resume at end of post, instead goes to top of post. Repro is to make a giant post, a small post, hit `k` on giant post.

- K does not work on post #1.

- Debounce bug is severe, if I hold K or J down stuff queues and gets super weird. (when you want to reach first post and there are only a few, then holding K seems easiest)

- Transition effect can be done smoother and with less CPU / JS. To be honest, I notice almost no issue on Firefox on my monster dev machine, but on my old laptop with Safari I notice this big time.

Once you get ⏫ sorted can you enable the theme component on all themes on meta? Then @zogstrip and @eviltrout who also like using these keys [cause Vim,](https://dribbble.com/shots/3086409-Vim) can test it.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [February 11, 2019, 2:19pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/9 "2019-02-11T14:19:32Z")

</div>

> [@sam](#):
>
> these keys [cause Vim,](https://dribbble.com/shots/3086409-Vim)

As a recent Vim convert, 😆

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 12, 2019, 3:45am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/10 "2019-02-12T03:45:20Z")

</div>

@dan fixed most of my list ❤ only open question is around making the nav a bit smoother, the downside of going native is that:

1. Safari does not support “smooth” built-in animation so we have to polyfill anyway
2. The “smooth” built-in nav is a lot slower than the 100ms transition we now have (about 400ms) so it would get in the way

Given (2) and that I am actually using this full-time now even on Safari and it is not getting in the way too much now that I am used to it. I think we are good for more extensive testing.

I enabled this on all themes on meta!

@zogstrip / @eviltrout can you try this for a few days and report back? Personally I think we should just ship this cause it works so much nicer than our previous implementation.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 12, 2019, 3:46am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/11 "2019-02-12T03:46:39Z")

</div>

> [@sam](#):
>
> Personally I think we should just ship this cause it works so much nicer than our previous implementation.

👍 definitely support that

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [February 12, 2019, 5:53am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/12 "2019-02-12T05:53:08Z")

</div>

Not much but good things to say on this one for the time being - namely

> [@dan](#):
>
> Long posts will scroll to full view before going to next post

I have to say that this was a huge painpoint with j/k keyboard shortcuts, and I think is a much better default. I do sometimes wish for a way to “go to next post”, when someone has a huge uninteresting walloftext and I just want to get to other responses, but it’s not as common as press j and --“hey I was reading that”.

I subscribe interest by way of emacs + evil ::ducks::

---

<div class="post-metadata">

### Author: ![TheBestPessimist](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thebestpessimist/32/247704_2.png) [@TheBestPessimist](https://meta.discourse.org/u/TheBestPessimist)
#### Post date: [February 12, 2019, 6:04am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/13 "2019-02-12T06:04:43Z")

</div>

This upgrade to navigation is AWESOME!

 ![](https://global.discourse-cdn.com/meta/original/3X/2/e/2e36cacc99343844a9aefbc217add73b8456876c.gif)

Must say i really hated having `j` jump to the next post when i was reading a really large post and just wanted to scroll down. (and i had to press `k` then scroll down with my mouse).

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [February 12, 2019, 2:30pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/14 "2019-02-12T14:30:11Z")

</div>

> [@dan](#):
>
> Long posts will scroll to full view before going to next post

This! I never realized how often I was hitting J just to hit K so I could use the down arrow to scroll through the entire post. Seeing this first hand was amazing.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [February 12, 2019, 4:50pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/15 "2019-02-12T16:50:30Z")

</div>

I used it all morning and it works much better than before. I did hit an edge case I didn’t love, where the post scrolled down just to show me the footer actions. I don’t think that part of the post should be included in the height calculations.

Otherwise I support putting this into core. I haven’t reviewed the code but functionally it works great.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 15, 2019, 9:14pm UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/16 "2019-02-15T21:14:07Z")

</div>

@dan this functionality should be merged into core and the component can be killed

If enough people complain (I doubt it) we can ship a component that reverts this

---

<div class="post-metadata">

### Author: ![dan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dan/32/101549_2.png) [@dan](https://meta.discourse.org/u/dan)
#### Post date: [July 12, 2019, 8:57am UTC](https://meta.discourse.org/t/smooth-j-k-navigation-when-using-keyboard/108634/20 "2019-07-12T08:57:33Z")

</div>


