1. /*
  2. * @(#)KeyListener.java 1.16 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.event;
  8. import java.util.EventListener;
  9. /**
  10. * The listener interface for receiving keyboard events (keystrokes).
  11. * The class that is interested in processing a keyboard event
  12. * either implements this interface (and all the methods it
  13. * contains) or extends the abstract <code>KeyAdapter</code> class
  14. * (overriding only the methods of interest).
  15. * <P>
  16. * The listener object created from that class is then registered with a
  17. * component using the component's <code>addKeyListener</code>
  18. * method. A keyboard event is generated when a key is pressed, released,
  19. * or typed (pressedn and released). The relevant method in the listener
  20. * object is then invoked, and the <code>KeyEvent</code> is passed to it.
  21. *
  22. * @author Carl Quinn
  23. * @version 1.16 01/23/03
  24. *
  25. * @see KeyAdapter
  26. * @see KeyEvent
  27. * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
  28. * @see <a href="http://www.awl.com/cp/javaseries/jcl1_2.html">Reference: The Java Class Libraries (update file)</a>
  29. *
  30. * @since 1.1
  31. */
  32. public interface KeyListener extends EventListener {
  33. /**
  34. * Invoked when a key has been typed.
  35. * See the class description for {@link KeyEvent} for a definition of
  36. * a key typed event.
  37. */
  38. public void keyTyped(KeyEvent e);
  39. /**
  40. * Invoked when a key has been pressed.
  41. * See the class description for {@link KeyEvent} for a definition of
  42. * a key pressed event.
  43. */
  44. public void keyPressed(KeyEvent e);
  45. /**
  46. * Invoked when a key has been released.
  47. * See the class description for {@link KeyEvent} for a definition of
  48. * a key released event.
  49. */
  50. public void keyReleased(KeyEvent e);
  51. }