How I can detect in which directions I scroll or type with my keyboard. Like how I detect if it left or right.
Asked
Active
Viewed 596 times
0
-
1Hiya, There is a good proof of concept residing here: http://stackoverflow.com/questions/1222915/can-one-use-window-onscroll-method-to-include-detection-of-scroll-direction ;(Capturing X and Y axis movement) hope this helps, cheers. – Tats_innit Mar 11 '12 at 20:05
2 Answers
1
You want to create a handler that detects a keydown event and then checks to see which key was pressed. Each keyboard key has an identifying number, which you can check and then handle appropriately. If it was the left arrow do one thing, if it's the right arrow, do another.
This question has been answered elsewhere on stackoverflow:
Binding arrow keys in JS/jQuery
You can read more about .keydown() at the jQuery API site.
-
Has the scrollwheel from the mouse a detection too? Because on my scollable I can scroll horizontally. – Azd325 Mar 11 '12 at 20:14
-
Ah, sorry, I missed that part of your question. I don't have any experience with it directly, but it's possible that http://api.jquery.com/scroll/ might have what you're looking for. It seems you can attach that event handler to the window object in addition to individual elements. It might catch all the different inputs that result in a scroll? – cmw Mar 11 '12 at 21:15
0
I was using the event object to get which event was triggerd MouseWheel or Keyboard
api.onBeforeSeek( function () { console.log(event);})
But I don't more using Jquery Tolls Scrollable because I was not best for my application.
I'm using now http://caroufredsel.frebsite.nl/ this much more powerful and flexible to use.

Azd325
- 5,752
- 5
- 34
- 57