本文整理汇总了Java中javafx.scene.input.KeyEvent.getEventType方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getEventType方法的具体用法?Java KeyEvent.getEventType怎么用?Java KeyEvent.getEventType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.getEventType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToList
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
private static void addToList(KeyEvent e) {
final StringBuilder sb = new StringBuilder();
if (e.getEventType() == KeyEvent.KEY_PRESSED) {
sb.append(checkModifier(e) + " pressed " + e.getCode());
}
if (e.getEventType() == KeyEvent.KEY_RELEASED) {
sb.append(checkModifier(e) + " released " + e.getCode());
}
kss.add(sb.toString().trim());
}
示例2: recordRawKeyEvent
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@Override public void recordRawKeyEvent(RFXComponent r, KeyEvent e) {
JSONObject event = new JSONObject();
event.put("type", "key_raw");
KeyCode keyCode = e.getCode();
if (keyCode.isModifierKey()) {
return;
}
if ((keyCode.isFunctionKey() || keyCode.isArrowKey() || keyCode.isKeypadKey() || keyCode.isMediaKey()
|| keyCode.isNavigationKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()
|| needManualRecording(keyCode)) && e.getEventType() == KeyEvent.KEY_PRESSED) {
String mtext = buildModifiersText(e);
event.put("modifiersEx", mtext);
KeysMap keysMap = KeysMap.findMap(e.getCode());
if (keysMap == KeysMap.NULL) {
return;
}
String keyText;
if (keysMap == null) {
keyText = e.getText();
} else {
keyText = keysMap.toString();
}
event.put("keyCode", keyText);
} else if (e.getEventType() == KeyEvent.KEY_TYPED && !e.isControlDown() && !needManualRecording(keyCode)) {
char[] cs = e.getCharacter().toCharArray();
if (cs.length == 0) {
return;
}
for (char c : cs) {
if (Character.isISOControl(c) && hasMapping(c)) {
event.put("keyChar", getMapping(c));
} else {
event.put("keyChar", "" + c);
}
}
} else {
return;
}
recordEvent(r, event);
}
示例3: handle
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@Override
public void handle(KeyEvent event) {
String code = event.getCode().getName().toLowerCase();
if(event.getEventType()==KeyEvent.KEY_PRESSED){
press.handle(code);
}else if(event.getEventType()==KeyEvent.KEY_RELEASED){
release.handle(code);
}
}
示例4: handle
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@Override public void handle(KeyEvent event) {
if (event.getEventType() != KeyEvent.KEY_PRESSED) {
return;
}
KeyCode code = event.getCode();
switch (code) {
case ENTER:
positionToLastLine();
boolean collect = false;
if (area.getText().toString().endsWith(";")) {
collect = true;
area.setText(area.getText().substring(0, area.getText().length() - 1));
}
if (collect || event.isShiftDown()) {
collectAction();
} else {
if (functionText.length() > 0) {
collectAction();
}
enterAction(event);
area.setEditable(false);
}
break;
case UP:
positionToLastLine();
upAction(event);
break;
case DOWN:
positionToLastLine();
downAction(event);
break;
case LEFT:
case D:
if (event.isControlDown()) {
event.consume();
inputJoin.send(Channel.LINE, EMPTY_LINE);
}
break;
default:
break;
}
}