This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 14687

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
Similar Threads
I want to trap a JScrollPane event when scolled up or down and perform some stuffs
JScrollPane with multiple JEditorPanes
check if ctrl-v was pressed in content editable area?
JScrollPane is scrolled down - how to set it up and let the user scroll is down?
How do you show a component that has focus?