Classe KeyEvent AWT
Inserendo il carattere viene generato l'evento chiave. Ci sono tre tipi di eventi chiave che sono rappresentati dalle costanti intere. Questi eventi chiave stanno seguendo
- KEY_PRESSED 
- KEY_RELASED 
- KEY_TYPED 
Dichiarazione di classe
Di seguito è riportata la dichiarazione per java.awt.event.KeyEvent classe:
public class KeyEvent
   extends InputEventCampo
Di seguito sono riportati i campi per java.awt.InputEvent classe:
- static char CHAR_UNDEFINED Gli eventi --KEY_PRESSED e KEY_RELEASED che non si associano a un carattere Unicode valido lo usano per il valore keyChar. 
- static int KEY_FIRST - Il primo numero nell'intervallo di ID utilizzato per gli eventi chiave. 
- static int KEY_LAST - L'ultimo numero nell'intervallo di ID utilizzato per gli eventi chiave. 
- static int KEY_LOCATION_LEFT - Una costante che indica che il tasto premuto o rilasciato si trova nella posizione del tasto sinistro (esiste più di una posizione possibile per questo tasto). 
- static int KEY_LOCATION_NUMPAD --Una costante che indica che l'evento chiave ha avuto origine sul tastierino numerico o con un tasto virtuale corrispondente al tastierino numerico. 
- static int KEY_LOCATION_RIGHT - Una costante che indica che il tasto premuto o rilasciato è nella giusta posizione della chiave (c'è più di una posizione possibile per questa chiave). 
- static int KEY_LOCATION_STANDARD - Una costante che indica che il tasto premuto o rilasciato non è distinto come versione sinistra o destra di un tasto e non ha avuto origine sul tastierino numerico (o non ha avuto origine con un tasto virtuale corrispondente al tastierino numerico). 
- static int KEY_LOCATION_UNKNOWN - Una costante che indica che keyLocation è indeterminato o non rilevante. 
- static int KEY_PRESSED - L'evento "tasto premuto". 
- static int KEY_RELEASED - L'evento "rilascio chiave". 
- static int KEY_TYPED - L'evento "digitato chiave". static int VK_0 --VK_0 fino a VK_9 sono gli stessi di ASCII da '0' a '9' (0x30 - 0x39)
- static int VK_1 
- static int VK_2 
- static int VK_3 
- static int VK_4 
- static int VK_5 
- static int VK_6 
- static int VK_7 
- static int VK_8 
- static int VK_9 
- static int VK_A --VK_A thru VK_Z sono gli stessi di ASCII 'A' thru 'Z' (0x41 - 0x5A) 
- static int VK_ACCEPT - Costante per il tasto funzione Accetta o Conferma. 
- static int VK_ADD 
- static int VK_AGAIN 
- static int VK_ALL_CANDIDATES - Costante per il tasto funzione Tutti i candidati. 
- static int VK_ALPHANUMERIC - Costante per il tasto funzione alfanumerico. 
- static int VK_ALT 
- static int VK_ALT_GRAPH - Costante per il tasto funzione AltGraph. 
- static int VK_AMPERSAND 
- static int VK_ASTERISK 
- static int VK_AT - costante per il tasto "@". 
- static int VK_B 
- static int VK_BACK_QUOTE 
- static int VK_BACK_SLASH - Costante per il tasto barra rovesciata, "\" 
- static int VK_BACK_SPACE 
- static int VK_BEGIN - Costante per la chiave Begin. 
- static int VK_BRACELEFT 
- static int VK_BRACERIGHT 
- static int VK_C 
- static int VK_CANCEL 
- static int VK_CAPS_LOCK 
- static int VK_CIRCUMFLEX - Costante per il tasto "^". 
- static int VK_CLEAR 
- static int VK_CLOSE_BRACKET - Costante per il tasto parentesi quadra chiusa, "]" 
- static int VK_CODE_INPUT - Costante per il tasto funzione di immissione del codice. 
- static int VK_COLON - Costante per il tasto ":". 
- static int VK_COMMA - Costante per la chiave virgola, "," 
- static int VK_COMPOSE - Costante per il tasto funzione Componi. 
- static int VK_CONTEXT_MENU - Costante per il tasto del menu contestuale di Microsoft Windows. 
- static int VK_CONTROL 
- static int VK_CONVERT - Costante per il tasto funzione Converti. 
- static int VK_COPY 
- static int VK_CUT 
- static int VK_D 
- static int VK_DEAD_ABOVEDOT 
- static int VK_DEAD_ABOVERING 
- static int VK_DEAD_ACUTE 
- static int VK_DEAD_BREVE 
- static int VK_DEAD_CARON 
- static int VK_DEAD_CEDILLA 
- static int VK_DEAD_CIRCUMFLEX 
- static int VK_DEAD_DIAERESIS 
- static int VK_DEAD_DOUBLEACUTE 
- static int VK_DEAD_GRAVE 
- static int VK_DEAD_IOTA 
- static int VK_DEAD_MACRON 
- static int VK_DEAD_OGONEK 
- static int VK_DEAD_SEMIVOICED_SOUND 
- static int VK_DEAD_TILDE 
- static int VK_DEAD_VOICED_SOUND 
- static int VK_DECIMAL 
- static int VK_DELETE 
- static int VK_DIVIDE 
- static int VK_DOLLAR - Costante per il tasto "$". 
- static int VK_DOWN - Costante per il tasto freccia giù non numerico. 
- static int VK_E 
- static int VK_END 
- static int VK_ENTER 
- static int VK_EQUALS --Costante per la chiave uguale, "=" 
- static int VK_ESCAPE 
- static int VK_EURO_SIGN - Costante per la chiave del segno di valuta Euro. 
- static int VK_EXCLAMATION_MARK - Costante per il "!" chiave. 
- static int VK_F 
- static int VK_F1 - Costante per il tasto funzione F1. 
- static int VK_F10 - Costante per il tasto funzione F10. 
- static int VK_F11 - Costante per il tasto funzione F11. 
- static int VK_F12 - Costante per il tasto funzione F12. 
- static int VK_F13 - Costante per il tasto funzione F13. 
- static int VK_F14 - Costante per il tasto funzione F14. 
- static int VK_F15 - Costante per il tasto funzione F15. 
- static int VK_F16 - Costante per il tasto funzione F16. 
- static int VK_F17 - Costante per il tasto funzione F17. 
- static int VK_F18 - Costante per il tasto funzione F18. 
- static int VK_F19 - Costante per il tasto funzione F19. 
- static int VK_F2 - Costante per il tasto funzione F2. 
- static int VK_F20 - Costante per il tasto funzione F20. 
- static int VK_F21 - Costante per il tasto funzione F21. 
- static int VK_F22 - Costante per il tasto funzione F22. 
- static int VK_F23 - Costante per il tasto funzione F23. 
- static int VK_F24 - Costante per il tasto funzione F24. 
- static int VK_F3 - Costante per il tasto funzione F3. 
- static int VK_F4 - Costante per il tasto funzione F4. 
- static int VK_F5 - Costante per il tasto funzione F5. 
- static int VK_F6 - Costante per il tasto funzione F6. 
- static int VK_F7 - Costante per il tasto funzione F7. 
- static int VK_F8 - Costante per il tasto funzione F8. 
- static int VK_F9 - Costante per il tasto funzione F9. 
- static int VK_FINAL 
- static int VK_FIND 
- static int VK_FULL_WIDTH --Costante per il tasto funzione Caratteri a larghezza intera. 
- static int VK_G 
- static int VK_GREATER 
- static int VK_H 
- static int VK_HALF_WIDTH --Costante per il tasto funzione Caratteri a metà larghezza. 
- static int VK_HELP 
- static int VK_HIRAGANA - Costante per il tasto funzione Hiragana. 
- static int VK_HOME 
- static int VK_I 
- static int VK_INPUT_METHOD_ON_OFF - Costante per il tasto di attivazione / disattivazione del metodo di input. 
- static int VK_INSERT 
- static int VK_INVERTED_EXCLAMATION_MARK - Costante per il punto esclamativo invertito. 
- static int VK_J 
- static int VK_JAPANESE_HIRAGANA --Costante per il tasto funzione giapponese-Hiragana. 
- static int VK_JAPANESE_KATAKANA - Costante per il tasto funzione giapponese-Katakana. 
- static int VK_JAPANESE_ROMAN - Costante per il tasto funzione giapponese-romano. 
- static int VK_K 
- static int VK_KANA 
- static int VK_KANA_LOCK - Costante per il blocco del tasto funzione Kana. 
- static int VK_KANJI 
- static int VK_KATAKANA - Costante per il tasto funzione Katakana. 
- static int VK_KP_DOWN - Costante per il tasto freccia giù del tastierino numerico. 
- static int VK_KP_LEFT - Costante per il tasto freccia sinistra del tastierino numerico. 
- static int VK_KP_RIGHT - Costante per il tasto freccia destra del tastierino numerico. 
- static int VK_KP_UP - Costante per il tasto freccia su del tastierino numerico. 
- static int VK_L 
- static int VK_LEFT - Costante per il tasto freccia sinistra non numerico. 
- static int VK_LEFT_PARENTHESIS - Costante per il tasto "(". 
- static int VK_LESS 
- static int VK_M 
- static int VK_META 
- static int VK_MINUS - Costante per il tasto meno, "-" 
- static int VK_MODECHANGE 
- static int VK_MULTIPLY 
- static int VK_N 
- static int VK_NONCONVERT - Costante per il tasto funzione Non convertire. 
- static int VK_NUM_LOCK 
- static int VK_NUMBER_SIGN - Costante per il tasto "#". 
- static int VK_NUMPAD0 
- static int VK_NUMPAD1 
- static int VK_NUMPAD2 
- static int VK_NUMPAD3 
- static int VK_NUMPAD4 
- static int VK_NUMPAD5 
- static int VK_NUMPAD6 
- static int VK_NUMPAD7 
- static int VK_NUMPAD8 
- static int VK_NUMPAD9 
- static int VK_O 
- static int VK_OPEN_BRACKET - Costante per la chiave delle parentesi graffe aperte, "[" 
- static int VK_P 
- static int VK_PAGE_DOWN 
- static int VK_PAGE_UP 
- static int VK_PASTE 
- static int VK_PAUSE 
- static int VK_PERIOD - Costante per la chiave del punto, "." 
- static int VK_PLUS - Costante per il tasto "+". 
- static int VK_PREVIOUS_CANDIDATE - Costante per il tasto funzione Candidato precedente. 
- static int VK_PRINTSCREEN 
- static int VK_PROPS 
- static int VK_Q 
- static int VK_QUOTE 
- static int VK_QUOTEDBL 
- static int VK_R 
- static int VK_RIGHT - Costante per il tasto freccia destra non numerico. 
- static int VK_RIGHT_PARENTHESIS - Costante per il tasto ")". 
- static int VK_ROMAN_CHARACTERS --Costante per il tasto funzione Caratteri romani. 
- static int VK_S 
- static int VK_SCROLL_LOCK 
- static int VK_SEMICOLON - Costante per il punto e virgola, ";" 
- static int VK_SEPARATER --Questa costante è obsoleta ed è inclusa solo per compatibilità con le versioni precedenti. 
- static int VK_SEPARATOR - Costante per il tasto separatore del tastierino numerico. 
- static int VK_SHIFT 
- static int VK_SLASH - Costante per il tasto barra in avanti, "/" 
- static int VK_SPACE 
- static int VK_STOP 
- static int VK_SUBTRACT 
- static int VK_T 
- static int VK_TAB 
- static int VK_U 
- static int VK_UNDEFINED - Questo valore viene utilizzato per indicare che il keyCode è sconosciuto. 
- static int VK_UNDERSCORE - Costante per il tasto "_". 
- static int VK_UNDO 
- static int VK_UP - Costante per il tasto freccia su senza tastierino numerico. 
- static int VK_V 
- static int VK_W 
- static int VK_WINDOWS - Costante per il tasto "Windows" di Microsoft Windows. 
- static int VK_X 
- static int VK_Y 
- static int VK_Z 
Costruttori di classi
| SN | Costruttore e descrizione | 
|---|---|
| 1 | KeyEvent(Component source, int id, long when, int modifiers, int keyCode) Deprecato. a partire da JDK1.1 | 
| 2 | KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar) Costruisce un oggetto KeyEvent. | 
| 3 | KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation) | 
Metodi di classe
| SN | Metodo e descrizione | 
|---|---|
| 1 | char getKeyChar() Restituisce il carattere associato alla chiave in questo evento. | 
| 2 | int getKeyCode() Restituisce il numero intero keyCode associato alla chiave in questo evento. | 
| 3 | int getKeyLocation() Restituisce la posizione della chiave che ha originato questo evento chiave. | 
| 4 | static String getKeyModifiersText(int modifiers) Restituisce una stringa che descrive i tasti di modifica, come "Maiusc" o "Ctrl + Maiusc". | 
| 5 | static String getKeyText(int keyCode) Restituisce una stringa che descrive il keyCode, ad esempio "HOME", "F1" o "A". | 
| 6 | boolean isActionKey() Restituisce se la chiave in questo evento è una chiave "azione". | 
| 7 | String paramString() Restituisce una stringa di parametri che identifica questo evento. | 
| 8 | void setKeyChar(char keyChar) Imposta il valore keyChar per indicare un carattere logico. | 
| 9 | void setKeyCode(int keyCode) Imposta il valore keyCode per indicare una chiave fisica. | 
| 10 | void setModifiers(int modifiers) Deprecato. a partire da JDK1.1.4 | 
Metodi ereditati
Questa classe eredita i metodi dalle classi seguenti:
- java.awt.event.InputEvent 
- java.awt.event.ComponentEvent 
- java.awt.AWTEvent 
- java.util.EventObject 
- java.lang.Object 
