Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple key strokes one action

Posted on 2007-11-22
3
Medium Priority
?
678 Views
Last Modified: 2012-06-21
I want to be able to bind more than one keystroke to the one action. The code below will bind ctrl+c to the action copyText. How can I also bind ctrl+ins to this?
KeyStroke controlC = KeyStroke.getKeyStroke("control C");  
Action copyText = textPane.getActionMap().get(textPane.getInputMap().get(controlC));

Open in new window

0
Comment
Question by:tomcorcoran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 20335212
Try

getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK);
0
 
LVL 17

Assisted Solution

by:contactkarthi
contactkarthi earned 200 total points
ID: 20336203
Here are some examples:

     "INSERT" => getKeyStroke(KeyEvent.VK_INSERT, 0);
     "control DELETE" => getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);
     "control INSERT" => getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_MASK);
     "alt shift X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
     "alt shift released X" => getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);
     "typed a" => getKeyStroke('a');
 
0
 

Author Closing Comment

by:tomcorcoran
ID: 31656913
Thanks guys, I,'m sure they answered the question I asked but the correct answer for me is to use the DefaultEditorKit
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question