Hi,

I have included some basic code that should do what you are after. The 
processStimulus() method simply goes through all the
criteria looking for KeyEvents (occur when a key is pressed, released and typed) then 
calls a seperate method to process them.
This seperate method, processKeyEvent() shows you how to tell if the key was pressed, 
released etc, and then shows how to tell
what key was pressed. In this case it is looking for the insert or delete keys. If you 
wanted to know when the 'A' key was
pressed then you would simply replace evt.VK_INSERT with evt.VK_A.

Hope this helps.

Cheers,

Brad



  public void processStimulus(Enumeration criteria) {
    WakeupCondition cond;
    AWTEvent[] events = null;

    while(criteria.hasMoreElements()) {
      cond = (WakeupCondition)criteria.nextElement();
      if(cond instanceof WakeupOnAWTEvent) {

        events = ((WakeupOnAWTEvent)cond).getAWTEvent();

        for(int i = 0; i < events.length; i++) {
            if(events[i] instanceof KeyEvent) {
              processKeyEvent((KeyEvent)events[i]);
            }
        }
      }
    }
    wakeupOn( wakeOn );
  }

  private void processKeyEvent(KeyEvent evt) {
    if(evt.getID() == evt.KEY_PRESSED) {
      System.out.println("Key event key pressed");
    }

    if(evt.getKeyCode() == evt.VK_INSERT) {
      ...
    } else if(evt.getKeyCode() == evt.VK_DELETE) {
      ...
    }
  }

TF wrote:
>
> I would like to know if there are any tutorials on behaviors that detail how
> to execute different behaviors, or to have your own behavior do different
> things when different keys are pressed or typed. If this is easy and someone
> can give me some actual or psuedo code of how this is done it would be
> greatly appreciated. I've looked through the archives of this mail group but
> All the questions on this never seem to end up with any clear answers. Thus
> far I've created a simple rotation behavior that when the user types a key
> it rotates in one direction (this is from the java3D tutorial on Sun's
> website), but it is not explained how to get the key codes from the event in
> order to utilize different keys being typed. Any help with this would be
> greatly appreciated.
>
> Eric
>
> ===========================================================================
> 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".


----------------------------------------------------------------------------
This Email may contain confidential and/or privileged information and is
intended solely for the addressee(s) named. If you have received this
information in error, or are advised that you have been posted this Email by
accident, please notify the sender by return Email, do not redistribute it,
delete the Email and keep no copies.
----------------------------------------------------------------------------

===========================================================================
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