0

Anyway to detect cotnrol key is down when mouse is clicked?

asked 2008-08-04 17:18:01 +0800

siamakh gravatar image siamakh
39

Hi,
I want to implement multiple selection by detecting if the CTRL key is down when the mouse is clicked, Is there anyway to do that?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2008-08-06 15:59:15 +0800

mcoughlin gravatar image mcoughlin
39

Yes there is. MouseEvent.getKeys() returns an integer indicating which keys are being held. If MouseEvent.getKeys() == MouseEvent.CTRL_KEY that means that the CTRL key was held at the time of the mouse click.

link publish delete flag offensive edit

answered 2008-08-07 01:12:03 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

Hi,
'keys' is bit flag, so i think the code logic should be

if(event.getKeys()&MouseEvent.CTRL_KEY != 0){

}

:)

/Dennis

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-08-04 17:18:01 +0800

Seen: 278 times

Last updated: Aug 07 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More