-
- All Superinterfaces:
- EventListener
- All Known Implementing Classes:
- AWTEventMulticaster, BasicComboBoxUI.KeyHandler, BasicComboPopup.InvocationKeyHandler, BasicTableUI.KeyHandler, BasicTreeUI.KeyHandler, KeyAdapter
public interface KeyListener extends EventListener
The listener interface for receiving keyboard events (keystrokes). The class that is interested in processing a keyboard event either implements this interface (and all the methods it contains) or extends the abstractKeyAdapter
class (overriding only the methods of interest).The listener object created from that class is then registered with a component using the component's
addKeyListener
method. A keyboard event is generated when a key is pressed, released, or typed. The relevant method in the listener object is then invoked, and theKeyEvent
is passed to it.- Since:
- 1.1
- See Also:
KeyAdapter
,KeyEvent
, Tutorial: Writing a Key Listener
-
-
Method Summary
Methods Modifier and Type Method and Description void
keyPressed(KeyEvent e)
Invoked when a key has been pressed.void
keyReleased(KeyEvent e)
Invoked when a key has been released.void
keyTyped(KeyEvent e)
Invoked when a key has been typed.
-
-
-
Method Detail
-
keyTyped
void keyTyped(KeyEvent e)
Invoked when a key has been typed. See the class description forKeyEvent
for a definition of a key typed event.
-
keyPressed
void keyPressed(KeyEvent e)
Invoked when a key has been pressed. See the class description forKeyEvent
for a definition of a key pressed event.
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-java/awt/event/KeyListener.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.