Use the Position Controller (a beta version is in the File Archive). It comes with an example of how to detect mouse movement.