'Shaking' the cursor

Tried to find some information on the forum, but I think the search terms might be a bit confusing…

What I want to do is be able to recognise a ‘shaking’ motion of the cursor - that is to say, call an event when the user moves the cursor rapidly back and forth along the x axis. I can get as far as determining when the cursor is moving in one direction at a certain speed, but recognising the repetitious change in direction is beyond me. It would be nice to have a class with parameters to change the max/min width and speed of the ‘shake’; failing that, any help in detecting the fact that the cusor is going back and forth would be very helpful.

[edit: Of course… ‘gestures’ is the search term I was after. Have now found all kinds of helpful stuff, but contributions to the thread still welcome…]