title: GWT: Checking if event handler exists
body: <p>I'm using a key up handler to add and remove event handlers depending on the string value of a text box. I wouldn't want to add or remove an event handler on every key up. How do I first check if a handler already exists?</p>
  
  <pre><code>HandlerRegistration firstHandler = null;
  HandlerRegistration secondHandler = null;
  
  public void onKeyUp(KeyUpEvent event) {
      if (countSpaceChar(textBox.getText()) == 0) {
          // code to check if MyFirstHandler is already attached?
          firstHandler = textBox.addKeyUpHandler(new MyFirstHandler(this)); 
      } if (countSpaceChar(textBox.getText()) == 1) {
          firstHandler.removeHandler();
          // code to check if MySecondHandler is already attached?
          secondHandler = textBox.addKeyUpHandler(new MySecondHandler(this));  
      } 
  
  }
  </code></pre>