Awt-key-event

提供:Dev Guides
移動先:案内検索

AWT KeyEventクラス

文字を入力すると、キーイベントが生成されます。整数定数で表されるキーイベントには3つのタイプがあります。 これらの主要なイベントは次のとおりです

  • KEY_PRESSED
  • KEY_RELASED
  • KEY_TYPED

クラス宣言

以下は java.awt.event.KeyEvent クラスの宣言です。

public class KeyEvent
   extends InputEvent

フィールド

*java.awt.InputEvent* クラスのフィールドは次のとおりです。
  • static char CHAR_UNDEFINED -有効なUnicode文字にマップされないKEY_PRESSEDおよびKEY_RELEASEDイベントは、これをkeyChar値に使用します。
  • static int KEY_FIRST -キーイベントに使用されるIDの範囲の最初の数値。
  • static int KEY_LAST -キーイベントに使用されるIDの範囲内の最後の数値。
  • static int KEY_LOCATION_LEFT -押されたまたは離されたキーが左のキーの場所にあることを示す定数です(このキーには複数の場所があります)。
  • static int KEY_LOCATION_NUMPAD -キーイベントが数値キーパッドまたは数値キーパッドに対応する仮想キーで発生したことを示す定数。
  • static int KEY_LOCATION_RIGHT -押されたまたは離されたキーが正しいキーの場所にあることを示す定数です(このキーには複数の場所があります)。
  • static int KEY_LOCATION_STANDARD -押されたまたは離されたキーがキーの左バージョンまたは右バージョンとして区別されず、数値キーパッドから生成されなかったこと(または数値に対応する仮想キーから生成されなかったことを示す定数)キーパッド)。
  • static int KEY_LOCATION_UNKNOWN -keyLocationが不定または関連しないことを示す定数。
  • static int KEY_PRESSED -「キーを押した」イベント。
  • static int KEY_RELEASED -「キーリリース」イベント。
  • static int KEY_TYPED -「キー入力」イベント。
  • 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はASCIIの「A」から「Z」と同じです(0x41-0x5A)
  • static int VK_ACCEPT -AcceptまたはCommitファンクションキーの定数。
  • static int VK_ADD
  • static int VK_AGAIN
  • static int VK_ALL_CANDIDATES -All Candidatesファンクションキーの定数。
  • static int VK_ALPHANUMERIC -英数字ファンクションキーの定数。
  • static int VK_ALT
  • static int VK_ALT_GRAPH --AltGraphファンクションキーの定数。
  • static int VK_AMPERSAND
  • static int VK_ASTERISK
  • static int VK_AT -「@」キーの定数。
  • static int VK_B
  • static int VK_BACK_QUOTE
  • static int VK_BACK_SLASH -バックスラッシュキー「\」の定数
  • static int VK_BACK_SPACE
  • static int VK_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 -「^」キーの定数。
  • static int VK_CLEAR
  • static int VK_CLOSE_BRACKET -角かっこキー「]」の定数
  • static int VK_CODE_INPUT -コード入力ファンクションキーの定数。
  • static int VK_COLON -「:」キーの定数。
  • static int VK_COMMA -コンマキー「、」の定数
  • static int VK_COMPOSE --Composeファンクションキーの定数。
  • static int VK_CONTEXT_MENU -Microsoft Windowsコンテキストメニューキーの定数。
  • static int VK_CONTROL
  • static int VK_CONVERT -Convertファンクションキーの定数。
  • 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 -「$」キーの定数。
  • static int VK_DOWN -テンキー以外の下矢印キーの定数。
  • static int VK_E
  • static int VK_END
  • static int VK_ENTER
  • static int VK_EQUALS -等号キーの定数、「=」
  • static int VK_ESCAPE
  • static int VK_EURO_SIGN -ユーロ通貨記号キーの定数。
  • static int VK_EXCLAMATION_MARK -「!」の定数キー。
  • static int VK_F
  • static int VK_F1 -F1ファンクションキーの定数。
  • static int VK_F10 -F10ファンクションキーの定数。
  • static int VK_F11 -F11ファンクションキーの定数。
  • static int VK_F12 -F12ファンクションキーの定数。
  • static int VK_F13 -F13ファンクションキーの定数。
  • static int VK_F14 -F14ファンクションキーの定数。
  • static int VK_F15 -F15ファンクションキーの定数。
  • static int VK_F16 -F16ファンクションキーの定数。
  • static int VK_F17 -F17ファンクションキーの定数。
  • static int VK_F18 -F18ファンクションキーの定数。
  • static int VK_F19 -F19ファンクションキーの定数。
  • static int VK_F2 -F2ファンクションキーの定数。
  • static int VK_F20 -F20ファンクションキーの定数。
  • static int VK_F21 -F21ファンクションキーの定数。
  • static int VK_F22 -F22ファンクションキーの定数。
  • static int VK_F23 -F23ファンクションキーの定数。
  • static int VK_F24 -F24ファンクションキーの定数。
  • static int VK_F3 -F3ファンクションキーの定数。
  • static int VK_F4 -F4ファンクションキーの定数。
  • static int VK_F5 -F5ファンクションキーの定数。
  • static int VK_F6 -F6ファンクションキーの定数。
  • static int VK_F7 -F7ファンクションキーの定数。
  • static int VK_F8 -F8ファンクションキーの定数。
  • static int VK_F9 -F9ファンクションキーの定数。
  • static int VK_FINAL
  • static int VK_FIND
  • static int VK_FULL_WIDTH -全角文字ファンクションキーの定数。
  • static int VK_G
  • static int VK_GREATER
  • static int VK_H
  • static int VK_HALF_WIDTH -半角文字ファンクションキーの定数。
  • static int VK_HELP
  • static int VK_HIRAGANA -ひらがなファンクションキーの定数。
  • static int VK_HOME
  • static int VK_I
  • static int VK_INPUT_METHOD_ON_OFF -入力メソッドのオン/オフキーの定数。
  • static int VK_INSERT
  • static int VK_INVERTED_EXCLAMATION_MARK -逆感嘆符キーの定数。
  • static int VK_J
  • static int VK_JAPANESE_HIRAGANA -日本語とひらがなのファンクションキーの定数。
  • static int VK_JAPANESE_KATAKANA -日本語カタカナファンクションキーの定数。
  • static int VK_JAPANESE_ROMAN -日本語-ローマ字ファンクションキーの定数。
  • static int VK_K
  • static int VK_KANA
  • static int VK_KANA_LOCK -ロックかな機能キーの定数。
  • static int VK_KANJI
  • static int VK_KATAKANA -カタカナファンクションキーの定数。
  • static int VK_KP_DOWN -テンキーの下矢印キーの定数。
  • static int VK_KP_LEFT -数値キーパッドの左矢印キーの定数。
  • static int VK_KP_RIGHT -テンキーの右矢印キーの定数。
  • static int VK_KP_UP -テンキーの上矢印キーの定数。
  • static int VK_L
  • static int VK_LEFT -テンキー以外の左矢印キーの定数。
  • static int VK_LEFT_PARENTHESIS -「(」キーの定数。
  • static int VK_LESS
  • static int VK_M
  • static int VK_META
  • static int VK_MINUS -マイナスキー「-」の定数
  • static int VK_MODECHANGE
  • static int VK_MULTIPLY
  • static int VK_N
  • static int VK_NONCONVERT -Do n’t Convertファンクションキーの定数。
  • static int VK_NUM_LOCK
  • static int VK_NUMBER_SIGN -「#」キーの定数。
  • 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 -オープンブラケットキー「[」の定数
  • 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 -期間キー「。」の定数
  • static int VK_PLUS -「+」キー用の定数です。
  • static int VK_PREVIOUS_CANDIDATE -前候補関数キーの定数。
  • 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 -テンキー以外の右矢印キーの定数。
  • static int VK_RIGHT_PARENTHESIS -「)」キーの定数。
  • static int VK_ROMAN_CHARACTERS -ローマ字ファンクションキーの定数。
  • static int VK_S
  • static int VK_SCROLL_LOCK
  • static int VK_SEMICOLON -セミコロンキー「;」の定数
  • static int VK_SEPARATER -この定数は廃止されており、後方互換性のためにのみ含まれています。
  • static int VK_SEPARATOR -Numpad Separatorキーの定数。
  • static int VK_SHIFT
  • static int VK_SLASH -スラッシュキーの定数「/」
  • 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 -この値は、keyCodeが不明であることを示すために使用されます。
  • static int VK_UNDERSCORE -「_」キーの定数。
  • static int VK_UNDO
  • static int VK_UP -テンキー以外の上矢印キーの定数。
  • static int VK_V
  • static int VK_W
  • static int VK_WINDOWS --Microsoft Windowsの「Windows」キーの定数。
  • static int VK_X
  • static int VK_Y
  • static int VK_Z

クラスコンストラクター

S.N. Constructor & Description
1

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

廃止予定です。 JDK1.1現在

2

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

KeyEventオブジェクトを構築します。

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

クラスメソッド

S.N. Method & Description
1

char getKeyChar()

このイベントのキーに関連付けられた文字を返します。

2

int getKeyCode()

このイベントのキーに関連付けられた整数のkeyCodeを返します。

3

int getKeyLocation()

このキーイベントを発生させたキーの位置を返します。

4

static String getKeyModifiersText(int modifiers)

「Shift」や「Ctrl + Shift」などの修飾キーを記述する文字列を返します。

5

static String getKeyText(int keyCode)

「HOME」、「F1」、「A」など、keyCodeを記述する文字列を返します。

6

boolean isActionKey()

このイベントのキーが「アクション」キーであるかどうかを返します。

7

String paramString()

このイベントを識別するパラメーター文字列を返します。

8

void setKeyChar(char keyChar)

keyChar値を設定して、論理文字を示します。

9

void setKeyCode(int keyCode)

keyCode値を設定して、物理キーを示します。

10

void setModifiers(int modifiers)

廃止予定です。 JDK1.1.4現在

継承されたメソッド

このクラスは、次のクラスからメソッドを継承します。

  • java.awt.event.InputEvent
  • java.awt.event.ComponentEvent
  • java.awt.AWTEvent
  • java.util.EventObject
  • java.lang.Object