Java tutorial
//package com.java2s; import java.awt.event.KeyEvent; import java.lang.reflect.Field; public class Main { /** * Returns the KeyEvent-code (only for VK_a..Z). * If no key-event could be found, {@link Integer#MIN_VALUE} is returned. */ public static int getKeyEvent(Character ch) { int ke = Integer.MIN_VALUE; try { Field f = KeyEvent.class.getField("VK_" + Character.toUpperCase(ch)); f.setAccessible(true); ke = (Integer) f.get(null); } catch (Exception e) { } return ke; } }