cheeaun / hackerweb

A simply readable Hacker News web app
http://hackerwebapp.com/
1.23k stars 133 forks source link

Add keyboard navigation #52

Open sbdchd opened 8 years ago

sbdchd commented 8 years ago

I think it would be convenient to be able to use the keyboard to navigate through posts.

sbdchd commented 8 years ago

I made a basic implementation of keyboard navigation, which works for the main page (not the comments).

See here.

Suggestions are much appreciated.

Keyboard Nav j - move down k - move up

o - open story c - open comments page

<backspace> - go to previous page (this is just normal browser behavior)

cheeaun commented 8 years ago

@sbdchd wow, that's really cool! I think you need e.preventDefault for the key presses, I enabled 'Search for text when I start typing' on my Firefox :stuck_out_tongue:

I'll further look at this during the weekend and see what I can do.

sbdchd commented 8 years ago

There seems to be an issue with this setup triggering more.

Sometimes, after more is triggered, the posts will become duplicated on the page.

In this case, the page will add on the items 31-60 multiple times to the current 1-30 posts.

When triggering more by hand this doesn't happen.