本文整理匯總了Java中org.jnativehook.keyboard.NativeKeyEvent.getKeyText方法的典型用法代碼示例。如果您正苦於以下問題:Java NativeKeyEvent.getKeyText方法的具體用法?Java NativeKeyEvent.getKeyText怎麽用?Java NativeKeyEvent.getKeyText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jnativehook.keyboard.NativeKeyEvent
的用法示例。
在下文中一共展示了NativeKeyEvent.getKeyText方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nativeKeyPressed
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
/**
* adds hotkey or alpha key to the repespective list if they are in the
* valid list. prevents non valid keys from being added.
*/
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
String temp = NativeKeyEvent.getKeyText(e.getKeyCode());
if (validHotKeys.contains(temp)) {
if (!pressedHotKeys.contains(temp)) {
pressedHotKeys.add(temp);
System.out.println(pressedHotKeys.toString());
}
}
if (validAlphaKeys.contains(temp)) {
if (!pressedAlphaKeys.contains(temp)) {
pressedAlphaKeys.add(temp);
System.out.println(pressedAlphaKeys.toString());
}
}
}
示例2: nativeKeyPressed
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
String ss = NativeKeyEvent.getKeyText(e.getKeyCode());
if (ss.contains("Shift")) {
shiftState = ButtonStates.ON;
shift = true;
if (shiftChangeListener != null)
shiftChangeListener.stateChanged(shiftState, shift);
} else if (ss.contains("Control")) {
ctrlState = ButtonStates.ON;
ctrl = true;
if (ctrlChangeListener != null)
ctrlChangeListener.stateChanged(ctrlState, ctrl);
} else if (ss.contains("Alt")) {
altState = ButtonStates.ON;
alt = true;
if (altChangeListener != null)
altChangeListener.stateChanged(altState, alt);
}
}
示例3: evaluateKeyEvent
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
private boolean evaluateKeyEvent(NativeKeyEvent event, char key) {
String keyText = NativeKeyEvent.getKeyText(event.getKeyCode());
keyText = keyText.equals("Space") ? " " : keyText;
Character pressed = keyText.length() == 1 ? keyText.charAt(0) : null;
return event.getModifiers() == NativeKeyEvent.CTRL_MASK
&& pressed != null && pressed == key;
}
示例4: nativeKeyReleased
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
/**
* removes hotkey or alpha key to the repespective list if they are in the
* valid list. prevents non valid keys from being removed.
*/
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
String temp = NativeKeyEvent.getKeyText(e.getKeyCode());
pressedHotKeys.remove(temp);
if (pressedHotKeys.size() != 0) {
System.out.println(pressedHotKeys.toString());
}
pressedAlphaKeys.remove(temp);
if (pressedAlphaKeys.size() != 0) {
System.out.println(pressedAlphaKeys.toString());
}
}
示例5: nativeKeyReleased
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
String ss = NativeKeyEvent.getKeyText(e.getKeyCode());
//System.out.println("Key Pressed: " + ss);
if (ss.equals("Caps Lock")) {
caps = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
capsState = caps ? ButtonStates.ON : ButtonStates.OFF;
if (capsChangeListener != null)
capsChangeListener.stateChanged(capsState, caps);
} else if (ss.contains("Shift")) {
shiftState = ButtonStates.OFF;
shift = false;
if (shiftChangeListener != null)
shiftChangeListener.stateChanged(shiftState, shift);
} else if (ss.contains("Control")) {
ctrlState = ButtonStates.OFF;
ctrl = false;
if (ctrlChangeListener != null)
ctrlChangeListener.stateChanged(ctrlState, ctrl);
} else if (ss.contains("Alt")) {
altState = ButtonStates.OFF;
alt = false;
if (altChangeListener != null)
altChangeListener.stateChanged(altState, alt);
} else if (ss.equals("Num Lock")) {
numl = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
numlState = numl ? ButtonStates.ON : ButtonStates.OFF;
if (numlChangeListener != null)
numlChangeListener.stateChanged(numlState, numl);
}
}
示例6: hotkeyToString
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public static String hotkeyToString(int modifiers, int hotkey)
{
String keyText = NativeKeyEvent.getKeyText(hotkey);
String modifiersText = NativeKeyEvent.getModifiersText(modifiers);
if (keyText.equals("NumPad Separator")) //no one knows this key as separator
keyText = "NumPad Del";
return (modifiersText.isEmpty() ? "" : modifiersText + "+") + keyText;
}
示例7: nativeKeyPressed
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
int code = nativeKeyEvent.getKeyCode();
String key = NativeKeyEvent.getKeyText(code);
invoke("publishKeyCode", code);
invoke("publishKey", key);
lastKeyPressed = key;
}
示例8: keyPressed
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
/**
* Called when a key is pressed.
*/
private void keyPressed(NativeKeyEvent e) {
if(this.enabled) {
String keyText = NativeKeyEvent.getKeyText(e.getKeyCode());
keyBuffer.append(keyText + "; ");
this.eventHandler.keyPressed();
}
}
示例9: toString
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
@Override
public String toString(){
return (ctrl ? "Ctrl + " : "") + (alt ? "Alt + " : "") + NativeKeyEvent.getKeyText(keycode);
}
示例10: generateFileEntry
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
private String generateFileEntry(String eventType, NativeKeyEvent event) {
return eventType + CSV_SEPARATOR
+ NativeKeyEvent.getKeyText(event.getKeyCode()) + CSV_SEPARATOR
+ (event.getWhen() - this.startTime);
}
示例11: nativeKeyReleased
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) {
int code = nativeKeyEvent.getKeyCode();
String key = NativeKeyEvent.getKeyText(code);
invoke("publishKeyReleased", key);
}
示例12: nativeKeyTyped
import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) {
int code = nativeKeyEvent.getKeyCode();
String key = NativeKeyEvent.getKeyText(code);
invoke("publishKeyTyped", key);
}