aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to detect the key combination of ctrl-v has been pressed down? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to detect the key combination of ctrl-v has been pressed down?" Watch "How to detect the key combination of ctrl-v has been pressed down?" New topic
Author

How to detect the key combination of ctrl-v has been pressed down?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598

What should go inside the braces of e.isControlDown()?
Thanks
Jack
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38902
    
  23
Go through the Java Tutorials with ctrl-F key and you find several things, about 5. I think these will be useful: 1 2.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

If you want to use it for clipboard support. You might find Clipboard interesting.
By the way I never worked with it and don't know if you should use it any longer.


Please correct my English.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4547
    
    5

Jacky Luk wrote:


When posting code on a forum, it's a good idea to remove inane IDE-generated comments which only add clutter.

It is never necessary to import classes from the java.lang package as the compiler automatically inserts an import-on-demand for java.lang.*

Rather than write your own empty implementations of all 3 KeyListener methods, you can extend KeyAdapter -- see the API.

If this is a Swing application, Kay Bindings are the way to go. Campbell has already posted a link to that particular section of the tutorials.


luck, db
There are no new questions, but there may be new answers.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598

A breakpoint in the code inside the Action event handler is never hit when I press ctrl-V. Why is that? I am sure I called addBindings()
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4547
    
    5

Looks like you didn't go through all of the Key Binding tutorial

Hint: ActionMap
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 598
Darryl Burke wrote:Looks like you didn't go through all of the Key Binding tutorial

Hint: ActionMap


Fine now. But the only problem is that the binding only happens once when I call this ActionMap + InputMap once in the constructor, do I have to hook this map to somewhere?
Thanks
Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to detect the key combination of ctrl-v has been pressed down?