I basically want to achieve the same effect as in Google Reader: when you press "j", you are pushed down to the next article and when you press "k", you can go back up to the previous article. What is the simplest way of doing this?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Using
onkeyup
and use thekeyCode
to determine the key pressed: http://jsfiddle.net/pimvdb/gzRwN/1/.Get the number/value for those keys and bind them to the event that you'd like them to execute. Much in the way that a
click
would be used to fire a function, but instead you're using a certain key.https://github.com/jeresig/jquery.hotkeys