Daryle Singh <[EMAIL PROTECTED]> on 07/07/99 01:35:41 AM
To: [EMAIL PROTECTED]
cc:  (bcc: Gary Moss/arl)
Subject: [JAVA3D] Decoding the wake up condition





Hi,
I am building a behaviour.The Stimulus  is KEYPRESSED.Any key.

Is it possible to decode the wakeup event and get the actual keycode
of the key pressed?


Any example code info appreciated.

 Try this:

 public void processStimulus( Enumeration criteria )
  {
  WakeupCriterion wakeup;
  AWTEvent[] event;
  int id;

  while( criteria.hasMoreElements() )
   {
   wakeup = (WakeupCriterion) criteria.nextElement();

   if( !(wakeup instanceof WakeupOnAWTEvent) )
    continue;

   event = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
   for( int i = 0; i < event.length; i++ )
    {
    id = event[i].getID();
    if( id == KeyEvent.KEY_PRESSED
       || id == KeyEvent.KEY_RELEASED )
     {
     KeyEvent ev = (KeyEvent)event[i];
     int keycode = ev.getKeyCode();
     if( keycode == KeyEvent.VK_UP
        || keycode == KeyEvent.VK_DOWN
        || keycode == KeyEvent.VK_LEFT
        || keycode == KeyEvent.VK_RIGHT )
      {
      // do stuff with arrow keys
      }
     }
    }
   }
  wakeupOn( keyCriterion );
  }

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to