Skip to content
Serhii Muslanov edited this page Apr 13, 2019 · 1 revision

Generate mouse events

There are three types of mouse events:

  • movement
  • buttons
  • wheel

Mouse buttons

There are three button constants that represent each mouse button:

  • LEFT
  • RIGHT
  • MIDDLE (middle button usually is wheel button)

Each button can perfom actions:

  • PRESS
  • RELEASE
  • CLICK (press + release)

To work with the mouse buttons and the wheel there is a built-in mouse object. Methods for working with buttons are similar to methods for working with keyboard keys(press, release, button, click). Look at the code below

mouse.press('LEFT');
mouse.release('LEFT');
        
mouse.button('RIGHT','PRESS');
mouse.button('RIGHT','RELEASE');

mouse.click('MIDDLE');

Also, the mouse object has methods for working with the scroll wheel. To control the mouse wheel, you must specify two parameters: the direction of scrolling "UP / DOWN" and the numeric parameter the number of lines.

mouse.wheel('DOWN',3);
mouse.wheel('UP',3);

Clone this wiki locally