List of usage examples for java.awt.event KeyEvent getExtendedKeyCodeForChar
public static int getExtendedKeyCodeForChar(int c)
From source file:KeyboardEmulator.java
public static String type(String s, boolean appendEnter) throws AWTException { if (isBlank(s)) return s; String typed = ""; try {// ww w .j ava 2 s .com Robot keyboard = getKeyboard(); int size = s.length(); char c; for (int i = 0; i < size; i++) { c = s.charAt(i); int idx = shiftChars.indexOf(c); if (idx > -1) { char cc = unShiftChars.charAt(idx); keyboard.keyPress(Shift); keyboard.keyPress(KeyEvent.getExtendedKeyCodeForChar(cc)); keyboard.keyRelease(KeyEvent.getExtendedKeyCodeForChar(cc)); keyboard.keyRelease(Shift); } else { keyboard.keyPress(KeyEvent.getExtendedKeyCodeForChar(c)); keyboard.keyRelease(KeyEvent.getExtendedKeyCodeForChar(c)); } typed += String.valueOf(c); } if (appendEnter) { keyboard.keyPress(Enter); keyboard.keyRelease(Enter); } } catch (AWTException e) { } finally { return typed; } }