Java Swing Key Event keyEventGetKeyText(int keycode)

Here you can find the source of keyEventGetKeyText(int keycode)

Description

key Event Get Key Text

License

Open Source License

Declaration

public static String keyEventGetKeyText(int keycode) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  // w w w .j a  v  a 2 s.c o m
 *  Copyright (C) 2010 Jalian Systems Private Ltd.
 *  Copyright (C) 2010 Contributors to Marathon OSS Project
 * 
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 * 
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 * 
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 *  Project website: http://www.marathontesting.com
 *  Help: Marathon help forum @ http://groups.google.com/group/marathon-testing
 * 
 *******************************************************************************/

import java.awt.event.KeyEvent;

public class Main {
    public static String keyEventGetKeyText(int keycode) {
        if (keycode == KeyEvent.VK_TAB)
            return "Tab";
        if (keycode == KeyEvent.VK_CONTROL)
            return "Ctrl";
        if (keycode == KeyEvent.VK_ALT)
            return "Alt";
        if (keycode == KeyEvent.VK_SHIFT)
            return "Shift";
        if (keycode == KeyEvent.VK_META)
            return "Command";
        if (keycode == KeyEvent.VK_SPACE)
            return "Space";
        if (keycode == KeyEvent.VK_BACK_SPACE)
            return "Backspace";
        if (keycode == KeyEvent.VK_HOME)
            return "Home";
        if (keycode == KeyEvent.VK_END)
            return "End";
        if (keycode == KeyEvent.VK_DELETE)
            return "Delete";
        if (keycode == KeyEvent.VK_PAGE_UP)
            return "Pageup";
        if (keycode == KeyEvent.VK_PAGE_DOWN)
            return "Pagedown";
        if (keycode == KeyEvent.VK_UP)
            return "Up";
        if (keycode == KeyEvent.VK_DOWN)
            return "Down";
        if (keycode == KeyEvent.VK_LEFT)
            return "Left";
        if (keycode == KeyEvent.VK_RIGHT)
            return "Right";
        if (keycode == KeyEvent.VK_ENTER)
            return "Enter";
        return KeyEvent.getKeyText(keycode);
    }
}

Related

  1. checkRowDownEvent(KeyEvent evt)
  2. esFecha(KeyEvent e)
  3. insertKeyListener(Component component, KeyListener l, int index)
  4. keyEventModifiersToKeyStrokeModifiers(int modifiers)
  5. keyStrokeModMac(String keyStrokeStr)
  6. press(int key)
  7. pressKey(final int key)