my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes Getting SHIFT key state Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Getting SHIFT key state" Watch "Getting SHIFT key state" New topic

Getting SHIFT key state

Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Ok, similar problem as the one I posted here couple of months ago...
Is there a way to know when the SHIFT is down?
I'm implementing some graphics editor, so I added MouseWheelListener to my drawing surface (extended from JPanel). When user scrolls up/down, all content is scrolled up/down. The effect I want to achieve is that when user holds SHIFT key and scrolls up/down, content is scrolled right/left.

The quieter you are, the more you are able to hear.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

By calling isShiftDown() on the event passed to your listener ?

[My Blog]
All roads lead to JavaRanch
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Oh... so simple... :-/
My bad... thanks!
I agree. Here's the link:
subject: Getting SHIFT key state
It's not a secret anymore!