protected boolean keyPressed ( KeyEvent e ) { logKey ( "keyPressed" , e ) ; // get the action command associated with this key int keyCode = e . getKeyCode ( ) ; boolean hasCommand = _xlate . hasCommand ( keyCode ) ; if ( hasCommand ) { // get the info object for this key, creating one if necessary KeyInfo info = _keys . get ( keyCode ) ; if ( info == null ) { info = new KeyInfo ( keyCode ) ; _keys . put ( keyCode , info ) ; } // remember the last time this key was pressed info . setPressTime ( RunAnywhere . getWhen ( e ) ) ; } // notify any key observers of the key press notifyObservers ( KeyEvent . KEY_PRESSED , e . getKeyCode ( ) , RunAnywhere . getWhen ( e ) ) ; return hasCommand ; }
Called when Swing notifies us that a key has been pressed while the keyboard manager is active .