How to combine two keys in keypressed() event?
Printable View
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
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?
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
Why does everything I post in end with me mentionng JNI nowdays :(
Chris
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:
Code :// 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 }