This tutorial shows how to detect mouse wheel scrolling in Scratch 1.4, 2.0 and 3.0.

Script

When the up or down arrow keys are inputted into the when () key pressed block, the block will also activate when the mouse is scrolled up or down, respective to the arrow key inputted. This exploit is not available with the key () pressed? block, as it only returns true if the arrow key is being pressed.

Add these scripts to the project:

when [up arrow v] key pressed
if <not <key (up arrow v) pressed?>> then
 . . . // runs when scrolling up
end

when [down arrow v] key pressed
if <not <key (down arrow v) pressed?>> then
 . . . // runs when scrolling down
end

The script activates repeatedly as the user scrolls their mouse.

Example Uses

  • Scrolling through a long webpage in an Operating System
  • Scrolling through a long menu in a project
  • Zooming in to see a piece of art

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.