Java examples for Swing:Key Event
Returns whether the key in this event is an "action" key.
/* $Id$//from w w w . j a va 2 s.co m ***************************************************************************** * Copyright (c) 2009 Contributors - see below * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * mvw ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ //package com.java2s; import java.awt.event.KeyEvent; public class Main { /** * Returns whether the key in this event is an "action" key. This is a * customization of KeyEvent#isActionKey() * * @param evt * the event to be verified * @return true if the event is an * @see java.awt.event.KeyEvent#isActionKey() */ public static final boolean isActionEvent(KeyEvent evt) { int keyCode = evt.getKeyCode(); switch (keyCode) { // Argo customization case KeyEvent.VK_BACK_SPACE: case KeyEvent.VK_DELETE: case KeyEvent.VK_CANCEL: // KeyEvent.isActionKey() method case KeyEvent.VK_HOME: case KeyEvent.VK_END: case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_KP_UP: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_KP_DOWN: case KeyEvent.VK_F1: case KeyEvent.VK_F2: case KeyEvent.VK_F3: case KeyEvent.VK_F4: case KeyEvent.VK_F5: case KeyEvent.VK_F6: case KeyEvent.VK_F7: case KeyEvent.VK_F8: case KeyEvent.VK_F9: case KeyEvent.VK_F10: case KeyEvent.VK_F11: case KeyEvent.VK_F12: case KeyEvent.VK_F13: case KeyEvent.VK_F14: case KeyEvent.VK_F15: case KeyEvent.VK_F16: case KeyEvent.VK_F17: case KeyEvent.VK_F18: case KeyEvent.VK_F19: case KeyEvent.VK_F20: case KeyEvent.VK_F21: case KeyEvent.VK_F22: case KeyEvent.VK_F23: case KeyEvent.VK_F24: case KeyEvent.VK_PRINTSCREEN: case KeyEvent.VK_SCROLL_LOCK: case KeyEvent.VK_CAPS_LOCK: case KeyEvent.VK_NUM_LOCK: case KeyEvent.VK_PAUSE: case KeyEvent.VK_INSERT: case KeyEvent.VK_FINAL: case KeyEvent.VK_CONVERT: case KeyEvent.VK_NONCONVERT: case KeyEvent.VK_ACCEPT: case KeyEvent.VK_MODECHANGE: case KeyEvent.VK_KANA: case KeyEvent.VK_KANJI: case KeyEvent.VK_ALPHANUMERIC: case KeyEvent.VK_KATAKANA: case KeyEvent.VK_HIRAGANA: case KeyEvent.VK_FULL_WIDTH: case KeyEvent.VK_HALF_WIDTH: case KeyEvent.VK_ROMAN_CHARACTERS: case KeyEvent.VK_ALL_CANDIDATES: case KeyEvent.VK_PREVIOUS_CANDIDATE: case KeyEvent.VK_CODE_INPUT: case KeyEvent.VK_JAPANESE_KATAKANA: case KeyEvent.VK_JAPANESE_HIRAGANA: case KeyEvent.VK_JAPANESE_ROMAN: case KeyEvent.VK_KANA_LOCK: case KeyEvent.VK_INPUT_METHOD_ON_OFF: case KeyEvent.VK_AGAIN: case KeyEvent.VK_UNDO: case KeyEvent.VK_COPY: case KeyEvent.VK_PASTE: case KeyEvent.VK_CUT: case KeyEvent.VK_FIND: case KeyEvent.VK_PROPS: case KeyEvent.VK_STOP: case KeyEvent.VK_HELP: return true; } return false; } }