[4737] in java-interest
Re: THANKS!
daemon@ATHENA.MIT.EDU (Kevin Conner)
Thu Jan 11 21:03:32 1996
Date: Thu, 11 Jan 1996 22:45:51 +0000
From: Kevin Conner <knrc@impltd.com>
To: Sian Tan <tan@cdr.stanford.edu>
Cc: java-interest@java.sun.com
Sian Tan wrote:
> There is another piece of functionality that I'm also trying to add:
>
> <CTRL + 'a key here'> functionality.
>
> The current code I have now is:
>
> ***************** Code *******************
> public boolean keyDown(Event e,int k)
> {
> if(k=='x' || k=='X')
> {
>
> ******* etc. etc. *******
>
> Can you help me with the syntax to put this into effect? It should be
> simple, but after some hacking, I still couldn't get it.
You are starting to get into something I have yet to try properly
but this is what I can find.
When you receive a keyDown message you can examine the modifiers
variable in the Event structure, this will tell you which modifiers
have been pressed (shift, ctrl, meta and alt). The key argument gives
the numeric value of the key pressed, CTRL-A to CTRL-Z being 1 to 26.
The following code should pick up CTRL-X key presses.
public boolean keyDown(Event evt, int key)
{
if ((evt.modifiers == evt.CTRL_MASK) && (key == '\030'))
{
// Key is CTRL-X and no other modifier were used
// Do CTRL-X processing
return true ;
}
return false ;
}
Good luck,
Kev
P.S. I have copied this to the mailing list in case there is a
better way to check for CTRL keys.
-----------------------------------------------------------------------
Kevin Conner knrc@impltd.com Integrated Micro Products
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com