Solved

Multiple key strokes one action

Posted on 2007-11-22
3
652 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
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 20335212
Try

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

Assisted Solution

by:contactkarthi
contactkarthi earned 50 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 95
eclipse shortcuts 9 55
ForLoop Example 3 48
varialbe initialization 11 33
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

773 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