How to combine two keys in keypressed() event?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How to combine two keys in keypressed() event?
I take it there will be two events, one for each key.
So for instance if you wish to check for CTRL + G being pushed you will have to do something like this.
1) Create code that sets a boolean to true if CTRL is pressed down, and set it back to false if the button is released
2) Create code that sets a boolean to true if G is pressed down, and set it back to false if the button is released
3) At each event, check if CTRL and G booleans are true and then you will know they both where pressed at the same time.
I think....
// Json
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Yes, the same thing JavaPF.Its working now.Thanks Json & JavaPF.But i have another doubt.Suppose i don't want the default action for keys like,
CONTROL+V is for paste.But i don't want to do this action.It have to perform some custom events.Is this possible?
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Something such as Ctrl-C is not a Windows default, its just a well recognised practise by windows. Each application has to interpret Ctrl-C in its own way...it doesn't have to do it. But either way you would have to interupt keyboard input at a system level, then do what ever and stop the message being passed on.
Not possible with standalone Java
Chris
Last edited by Freaky Chris; August 28th, 2009 at 07:51 AM.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
Why does everything I post in end with me mentionng JNI nowdays
Chris
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
C++...not used it in ages though really lol!
Lol, i've forgotten much of the C++ syntax. The other day, i tried doing this:
// I know it says Java Code, but I was doing this in C++ public class Date { String month; int day; int year; // ... rest of code }