本文整理了Java中java.awt.event.KeyEvent.getExtendedKeyCodeForChar()
方法的一些代码示例,展示了KeyEvent.getExtendedKeyCodeForChar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getExtendedKeyCodeForChar()
方法的具体详情如下:
包路径:java.awt.event.KeyEvent
类名称:KeyEvent
方法名:getExtendedKeyCodeForChar
暂无
代码示例来源:origin: stackoverflow.com
import java.awt.event.KeyEvent;
[...]
public static void type(Robot robot, String word) {
for (int i = 0; i < word.length(); i++) {
int keyCode = KeyEvent.getExtendedKeyCodeForChar(word.charAt(i));
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
}
}
[...]
Robot robot = new Robot();
type(robot, "hallo");
代码示例来源:origin: BaseXdb/basex
/**
* Returns true if the specified key combination was pressed.
* @param e key event
* @return result of check
*/
public boolean is(final KeyEvent e) {
final int c = e.getKeyCode();
final int m = e.getModifiersEx() | allowed;
return m == (modifiers | allowed) &&
(c == VK_UNDEFINED ? getExtendedKeyCodeForChar(e.getKeyChar()) : c) == key;
}
代码示例来源:origin: org.basex/basex
/**
* Returns true if the specified key combination was pressed.
* @param e key event
* @return result of check
*/
public boolean is(final KeyEvent e) {
final int c = e.getKeyCode();
final int m = e.getModifiersEx() | allowed;
return m == (modifiers | allowed) &&
(c == VK_UNDEFINED ? getExtendedKeyCodeForChar(e.getKeyChar()) : c) == key;
}
代码示例来源:origin: com.nelkinda.japi/nelkinda-japi-swing
private static Map<String, Function<String, ?>> createActionConverters() {
final Function<String, String> identity = identity();
final Map<String, Function<String, ?>> actionConverters = new HashMap<>();
actionConverters.put(ACCELERATOR_KEY, KeyStroke::getKeyStroke);
actionConverters.put(DISPLAYED_MNEMONIC_INDEX_KEY, Integer::parseInt);
actionConverters.put(NAME, identity);
actionConverters.put(MNEMONIC_KEY, s -> getExtendedKeyCodeForChar(s.codePointAt(0)));
actionConverters.put(SHORT_DESCRIPTION, identity);
actionConverters.put(LONG_DESCRIPTION, identity);
actionConverters.put(SMALL_ICON, SwingUtilitiesN::getImageIcon);
actionConverters.put(LARGE_ICON_KEY, SwingUtilitiesN::getImageIcon);
return unmodifiableMap(actionConverters);
}
}
代码示例来源:origin: gurkenlabs/litiengine
private String getAltText(KeyEvent e) {
if (e.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ß')) {
return "\\";
}
switch (e.getKeyCode()) {
case KeyEvent.VK_0:
return "}";
case KeyEvent.VK_2:
return "²";
case KeyEvent.VK_3:
return "³";
case KeyEvent.VK_7:
return "{";
case KeyEvent.VK_8:
return "[";
case KeyEvent.VK_9:
return "]";
case KeyEvent.VK_E:
return "€";
case KeyEvent.VK_Q:
return "@";
case KeyEvent.VK_M:
return "µ";
case KeyEvent.VK_PLUS:
return "~";
default:
return "";
}
}
代码示例来源:origin: chatty/chatty
private void addKey(CommandMenuItem item, JMenuItem mItem) {
if (item.hasKey()) {
mItem.setMnemonic(KeyEvent.getExtendedKeyCodeForChar(item.getKey().toLowerCase().charAt(0)));
}
}
代码示例来源:origin: com.anrisoftware.globalpom/globalpomutils-core
/**
* Returns the key code for the name. The name can be a character or a key
* code constant starting with {@code "VK_"} or key mask that ends with
* {@code "_MASK"}.
*
* @param keyname
* the key code name.
*
* @return the key code or {@code null} if the key code name does not have a
* key code.
*
* @see KeyEvent
* @see KeyEvent#getExtendedKeyCodeForChar(int)
*/
public Integer getKeyCode(String keyname) {
if (keyname.startsWith("VK_")) {
Map<String, Integer> codes = getKeyCodes();
return codes.get(keyname);
}
if (keyname.endsWith("_MASK")) {
Map<String, Integer> codes = getKeyCodes();
return codes.get(keyname);
}
if (keyname.length() == 1) {
return KeyEvent.getExtendedKeyCodeForChar(keyname.charAt(0));
} else {
return null;
}
}
代码示例来源:origin: gurkenlabs/litiengine
private String getNormalText(KeyEvent e) {
if (e.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ß')) {
return "ß";
代码示例来源:origin: gurkenlabs/litiengine
private String getShiftText(KeyEvent e) {
if (e.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ß')) {
return "?";
代码示例来源:origin: stackoverflow.com
int code = KeyEvent.getExtendedKeyCodeForChar(c);
robot.keyPress(code);
robot.keyRelease(code);
代码示例来源:origin: comtel2000/fx-experience
int keycode = KeyEvent.getExtendedKeyCodeForChar(ch);
if (keycode != KeyEvent.VK_UNDEFINED) {
kfm.dispatchKeyEvent(new KeyEvent(c, KEY_PRESSED, System.currentTimeMillis(), controlDownMask, keycode, ch, KEY_LOCATION_STANDARD));
代码示例来源:origin: comtel2000/fx-experience
int keyCode = getExtendedKeyCodeForChar(ch);
if (Character.isWhitespace(ch)) {
robot.keyPress(keyCode);
内容来源于网络,如有侵权,请联系作者删除!