Classe AWT KeyEvent

Lors de la saisie du caractère, l'événement Key est généré. Il existe trois types d'événements clés qui sont représentés par les constantes entières. Ces événements clés suivent

  • KEY_PRESSED

  • KEY_RELASED

  • KEY_TYPED

Déclaration de classe

Voici la déclaration pour java.awt.event.KeyEvent classe:

public class KeyEvent
   extends InputEvent

Champ

Voici les champs pour java.awt.InputEvent classe:

  • static char CHAR_UNDEFINED - Les événements KEY_PRESSED et KEY_RELEASED qui ne correspondent pas à un caractère Unicode valide l'utilisent pour la valeur keyChar.

  • static int KEY_FIRST - Le premier numéro de la plage d'ID utilisés pour les événements clés.

  • static int KEY_LAST - Le dernier numéro de la plage d'ID utilisés pour les événements clés.

  • static int KEY_LOCATION_LEFT --Une constante indiquant que la touche enfoncée ou relâchée se trouve à l'emplacement de la touche gauche (il y a plus d'un emplacement possible pour cette touche).

  • static int KEY_LOCATION_NUMPAD - Une constante indiquant que l'événement de touche provient du pavé numérique ou d'une touche virtuelle correspondant au pavé numérique.

  • static int KEY_LOCATION_RIGHT - Une constante indiquant que la touche enfoncée ou relâchée se trouve au bon emplacement de la touche (il y a plus d'un emplacement possible pour cette touche).

  • static int KEY_LOCATION_STANDARD - Une constante indiquant que la touche enfoncée ou relâchée n'est pas distinguée comme la version gauche ou droite d'une touche, et ne provient pas du pavé numérique (ou ne provient pas d'une touche virtuelle correspondant au pavé numérique).

  • static int KEY_LOCATION_UNKNOWN - Une constante indiquant que keyLocation est indéterminé ou non pertinent.

  • static int KEY_PRESSED - L'événement "touche enfoncée".

  • static int KEY_RELEASED - L'événement "clé relâchée".

  • static int KEY_TYPED - L'événement "clé tapée".

  • static int VK_0 --VK_0 à VK_9 sont les mêmes que ASCII '0' à '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 à VK_Z sont les mêmes que ASCII 'A' à 'Z' (0x41 - 0x5A)

  • static int VK_ACCEPT --Constante pour la touche de fonction Accepter ou Valider.

  • static int VK_ADD

  • static int VK_AGAIN

  • static int VK_ALL_CANDIDATES --Constante pour la touche de fonction Tous les candidats.

  • static int VK_ALPHANUMERIC --Constante pour la touche de fonction alphanumérique.

  • static int VK_ALT

  • static int VK_ALT_GRAPH --Constante pour la touche de fonction AltGraph.

  • static int VK_AMPERSAND

  • static int VK_ASTERISK

  • static int VK_AT --constant pour la touche "@".

  • static int VK_B

  • static int VK_BACK_QUOTE

  • static int VK_BACK_SLASH --Constante pour la touche barre oblique inverse, "\"

  • static int VK_BACK_SPACE

  • static int VK_BEGIN - Constante pour la touche Début.

  • 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 --Constante pour la touche "^".

  • static int VK_CLEAR

  • static int VK_CLOSE_BRACKET --Constante pour la clé de parenthèse fermée, "]"

  • static int VK_CODE_INPUT --Constante pour la touche de fonction Entrée de code.

  • static int VK_COLON --Constante pour la touche ":".

  • static int VK_COMMA --Constante pour la touche virgule, ","

  • static int VK_COMPOSE --Constante pour la touche de fonction Composer.

  • static int VK_CONTEXT_MENU --Constante pour la touche du menu contextuel de Microsoft Windows.

  • static int VK_CONTROL

  • static int VK_CONVERT - Constante pour la touche de fonction Convertir.

  • 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 --Constante pour la touche "$".

  • static int VK_DOWN - Constante pour la touche fléchée vers le bas non numérique.

  • static int VK_E

  • static int VK_END

  • static int VK_ENTER

  • static int VK_EQUALS --Constante pour la clé égale, "="

  • static int VK_ESCAPE

  • static int VK_EURO_SIGN -Constante pour la clé de signe de devise Euro.

  • static int VK_EXCLAMATION_MARK --Constante pour le "!" clé.

  • static int VK_F

  • static int VK_F1 --Constante pour la touche de fonction F1.

  • static int VK_F10 - Constante pour la touche de fonction F10.

  • static int VK_F11 --Constante pour la touche de fonction F11.

  • static int VK_F12 --Constante pour la touche de fonction F12.

  • static int VK_F13 --Constante pour la touche de fonction F13.

  • static int VK_F14 --Constante pour la touche de fonction F14.

  • static int VK_F15 --Constante pour la touche de fonction F15.

  • static int VK_F16 - Constante pour la touche de fonction F16.

  • static int VK_F17 --Constante pour la touche de fonction F17.

  • static int VK_F18 - Constante pour la touche de fonction F18.

  • static int VK_F19 --Constante pour la touche de fonction F19.

  • static int VK_F2 - Constante pour la touche de fonction F2.

  • static int VK_F20 --Constante pour la touche de fonction F20.

  • static int VK_F21 - Constante pour la touche de fonction F21.

  • static int VK_F22 - Constante pour la touche de fonction F22.

  • static int VK_F23 - Constante pour la touche de fonction F23.

  • static int VK_F24 --Constante pour la touche de fonction F24.

  • static int VK_F3 - Constante pour la touche de fonction F3.

  • static int VK_F4 - Constante pour la touche de fonction F4.

  • static int VK_F5 - Constante pour la touche de fonction F5.

  • static int VK_F6 --Constante pour la touche de fonction F6.

  • static int VK_F7 - Constante pour la touche de fonction F7.

  • static int VK_F8 - Constante pour la touche de fonction F8.

  • static int VK_F9 --Constante pour la touche de fonction F9.

  • static int VK_FINAL

  • static int VK_FIND

  • static int VK_FULL_WIDTH --Constante pour la touche de fonction Caractères pleine largeur.

  • static int VK_G

  • static int VK_GREATER

  • static int VK_H

  • static int VK_HALF_WIDTH --Constante pour la touche de fonction Caractères demi-largeur.

  • static int VK_HELP

  • static int VK_HIRAGANA - Constante pour la touche de fonction Hiragana.

  • static int VK_HOME

  • static int VK_I

  • static int VK_INPUT_METHOD_ON_OFF - Constante pour la touche marche / arrêt de la méthode d'entrée.

  • static int VK_INSERT

  • static int VK_INVERTED_EXCLAMATION_MARK --Constante pour la touche de point d'exclamation inversé.

  • static int VK_J

  • static int VK_JAPANESE_HIRAGANA --Constante pour la touche de fonction Japanese-Hiragana.

  • static int VK_JAPANESE_KATAKANA --Constante pour la touche de fonction japonais-katakana.

  • static int VK_JAPANESE_ROMAN --Constante pour la touche de fonction japonais-romain.

  • static int VK_K

  • static int VK_KANA

  • static int VK_KANA_LOCK - Constante pour la touche de fonction de verrouillage Kana.

  • static int VK_KANJI

  • static int VK_KATAKANA - Constante pour la touche de fonction Katakana.

  • static int VK_KP_DOWN - Constante pour la touche fléchée bas du clavier numérique.

  • static int VK_KP_LEFT --Constante pour la touche fléchée gauche du pavé numérique.

  • static int VK_KP_RIGHT --Constante pour la touche fléchée droite du pavé numérique.

  • static int VK_KP_UP --Constante pour la touche fléchée vers le haut du pavé numérique.

  • static int VK_L

  • static int VK_LEFT --Constante pour la touche fléchée gauche non numérique.

  • static int VK_LEFT_PARENTHESIS --Constante pour la touche "(".

  • static int VK_LESS

  • static int VK_M

  • static int VK_META

  • static int VK_MINUS - Constante pour la touche moins, "-"

  • static int VK_MODECHANGE

  • static int VK_MULTIPLY

  • static int VK_N

  • static int VK_NONCONVERT - Constante pour la touche de fonction Ne pas convertir.

  • static int VK_NUM_LOCK

  • static int VK_NUMBER_SIGN --Constante pour la touche "#".

  • 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 --Constante pour la clé de parenthèse ouverte, "["

  • 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 --Constante pour la clé de période, "."

  • static int VK_PLUS - Constante pour la touche "+".

  • static int VK_PREVIOUS_CANDIDATE - Constante pour la touche de fonction Candidat précédent.

  • 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 - Constante pour la touche fléchée droite non numérique.

  • static int VK_RIGHT_PARENTHESIS --Constante pour la touche ")".

  • static int VK_ROMAN_CHARACTERS --Constante pour la touche de fonction Caractères romains.

  • static int VK_S

  • static int VK_SCROLL_LOCK

  • static int VK_SEMICOLON - Constante pour la touche point-virgule, ";"

  • static int VK_SEPARATER - Cette constante est obsolète et n'est incluse qu'à des fins de compatibilité ascendante.

  • static int VK_SEPARATOR --Constante pour la touche de séparation du pavé numérique.

  • static int VK_SHIFT

  • static int VK_SLASH - Constante pour la touche barre oblique, "/"

  • 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 - Cette valeur est utilisée pour indiquer que le keyCode est inconnu.

  • static int VK_UNDERSCORE --Constante pour la touche "_".

  • static int VK_UNDO

  • static int VK_UP --Constante pour la touche fléchée vers le haut sans pavé numérique.

  • static int VK_V

  • static int VK_W

  • static int VK_WINDOWS --Constante pour la touche "Windows" de Microsoft Windows.

  • static int VK_X

  • static int VK_Y

  • static int VK_Z

Constructeurs de classe

SN Constructeur et description
1

KeyEvent(Component source, int id, long when, int modifiers, int keyCode)

Obsolète. à partir de JDK1.1

2

KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar)

Construit un objet KeyEvent.

3

KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation)

Méthodes de classe

SN Méthode et description
1

char getKeyChar()

Renvoie le caractère associé à la clé dans cet événement.

2

int getKeyCode()

Renvoie le keyCode entier associé à la clé dans cet événement.

3

int getKeyLocation()

Renvoie l'emplacement de la clé à l'origine de cet événement de clé.

4

static String getKeyModifiersText(int modifiers)

Renvoie une chaîne décrivant la ou les touches de modification, telles que "Shift" ou "Ctrl + Shift".

5

static String getKeyText(int keyCode)

Renvoie une chaîne décrivant le keyCode, telle que "HOME", "F1" ou "A".

6

boolean isActionKey()

Renvoie si la clé de cet événement est une clé "action".

sept

String paramString()

Renvoie une chaîne de paramètres identifiant cet événement.

8

void setKeyChar(char keyChar)

Définissez la valeur keyChar pour indiquer un caractère logique.

9

void setKeyCode(int keyCode)

Définissez la valeur keyCode pour indiquer une clé physique.

dix

void setModifiers(int modifiers)

Obsolète. à partir de JDK1.1.4

Méthodes héritées

Cette classe hérite des méthodes des classes suivantes:

  • java.awt.event.InputEvent

  • java.awt.event.ComponentEvent

  • java.awt.AWTEvent

  • java.util.EventObject

  • java.lang.Object