/** * MIT License * * Copyright (c) 2017 zgqq * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package mah.keybind.util; import java.awt.event.KeyEvent; /** * Created by zgq on 2017-01-09 09:28 */ public class SwingUtils { public static final int getKeyCode(char c) { switch (c) { case '[': return KeyEvent.VK_OPEN_BRACKET; case ']': return KeyEvent.VK_CLOSE_BRACKET; case '`': return KeyEvent.VK_DEAD_GRAVE; case ' ': return KeyEvent.VK_SPACE; case '-': return KeyEvent.VK_MINUS; case '=': return KeyEvent.VK_EQUALS; case '.': return KeyEvent.VK_PERIOD; case '/': return KeyEvent.VK_SLASH; case 'a': return KeyEvent.VK_A; case 'b': return KeyEvent.VK_B; case 'c': return KeyEvent.VK_C; case 'd': return KeyEvent.VK_D; case 'e': return KeyEvent.VK_E; case 'f': return KeyEvent.VK_F; case 'g': return KeyEvent.VK_G; case 'h': return KeyEvent.VK_H; case 'i': return KeyEvent.VK_I; case 'j': return KeyEvent.VK_J; case 'k': return KeyEvent.VK_K; case 'l': return KeyEvent.VK_L; case 'm': return KeyEvent.VK_M; case 'n': return KeyEvent.VK_N; case 'o': return KeyEvent.VK_O; case 'p': return KeyEvent.VK_P; case 'q': return KeyEvent.VK_Q; case 'r': return KeyEvent.VK_R; case 's': return KeyEvent.VK_S; case 't': return KeyEvent.VK_T; case 'u': return KeyEvent.VK_U; case 'v': return KeyEvent.VK_V; case 'w': return KeyEvent.VK_W; case 'x': return KeyEvent.VK_X; case 'y': return KeyEvent.VK_Y; case 'z': return KeyEvent.VK_Z; case '1': return KeyEvent.VK_1; case '2': return KeyEvent.VK_2; case '3': return KeyEvent.VK_3; case '4': return KeyEvent.VK_4; case '5': return KeyEvent.VK_5; case '6': return KeyEvent.VK_6; case '7': return KeyEvent.VK_7; case '8': return KeyEvent.VK_8; case '9': return KeyEvent.VK_9; case '0': return KeyEvent.VK_0; default: break; } return -1; } }