keyevent

Cannot listen to KeyEvent in JavaFX

ε祈祈猫儿з 提交于 2019-11-30 13:50:53
I want my JavaFX program to respond to keyboard events. I tried adding listeners to root Pane , to topmost Pane , but it doesn't respond to events! Here is my code: AnchorPane root = new AnchorPane(); root.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { pressKey(t.getCharacter().charAt(0)); } }); root.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { releaseKey(t.getCharacter().charAt(0)); } }); root.addEventHandler(EventType.ROOT, new EventHandler<Event>() { @Override public void handle(Event t) { if (t

Android soft keyboard in a fullscreen Surface View

China☆狼群 提交于 2019-11-30 09:53:51
问题 HI! I am currently extending an Android Game Framework,which I found in a Book written by Mario Zechner (who also develops Libgdx). It is working great so far and I accomplished a Java Desktop Implementation of the Framework. But one tiny thing is missing, the correct usage of the SoftKeyboard. You can try out and reproduce my bug , the whole project is on github, and the android module is the "app"folder. The java version (left arrow key = key back) is in the javalib module. https://github

Android - Get keyboard key press

拥有回忆 提交于 2019-11-30 06:24:56
问题 I want to catch the press of any key of the softkeyboard. I don't want a EditView or TextView in my Activity, the event must be handled from a extended View inside my Activity. I just tried this: 1) Override the onKeyUp(int keyCode, KeyEvent event) Activity method. This don't work with softkeyboard, it just catch few hardkeyboard. 2) Create my OnKeyListener and register that in my View that contains a registered and working OnTouchListener . This doesn't work at all with softkeyboard. 3)

Check Keyboard Input Winforms

若如初见. 提交于 2019-11-30 06:09:44
问题 I was wondering if instead of doing this protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.A) Console.WriteLine("The A key is down."); } I could set up a bool method and do this: if(KeyDown(Keys.A)) // do whatever here I've been sitting here for ages trying to figure out how to do it. But I just can't wrap my head around it. In case you were wondering, my plan is to call the bool inside a different method, to check for input. 回答1: Since you usually want to perform an

Android soft keyboard in a fullscreen Surface View

纵然是瞬间 提交于 2019-11-29 18:14:40
HI! I am currently extending an Android Game Framework,which I found in a Book written by Mario Zechner (who also develops Libgdx). It is working great so far and I accomplished a Java Desktop Implementation of the Framework. But one tiny thing is missing, the correct usage of the SoftKeyboard. You can try out and reproduce my bug , the whole project is on github, and the android module is the "app"folder. The java version (left arrow key = key back) is in the javalib module. https://github.com/Railwanderer/AndroidGameFramework The Framework uses Window FullScreenFlags and NoTitle Flags in

Make a KeyEvent in Java only happen once even when key is held

人走茶凉 提交于 2019-11-29 16:25:21
I need to know if it is possible to have an action only happen once when a key is pressed, even if that key is held down for some time, and if it is possible, how? This is the code I have for that now: if(e.getKeyCode() == KeyEvent.VK_A) { attack = true; moveX = -5; draw(moveX, moveY); players.get(username).setImageIcon("attack-left"); } This is within the keyPressed method, and in the keyReleased I set moveX to 0. So if A is pressed the image is supposed to 5 units to the left and stop, regardless of whether or not A is still being held down or it has been released. But this is not working,

KeyEvent special Keys (like mute)

偶尔善良 提交于 2019-11-29 15:28:41
问题 I'm currently trying to create a little remote-app for Android to control a MediaPlayer (like Rythmbox) on my PC. Most media-players understand the special keys on my keyboard (like "play/pause" or "next/previous"). My idea is that the Android App sends a command (like "pause") to the PC. On the PC runs a normal Java-Application which receives this commands and simulates a key-press of this special button. The advantage would be that you can use this App on all platforms for every player

How can I listen to a TAB key pressed/typed in Java?

旧街凉风 提交于 2019-11-29 09:07:40
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { //cant capture my TAB? System.out.print(evt.getKeyChar()); } What is the simplest way in an java gui to capture the tab key without doing using the focus listening technique? VK_TAB is the tab constant. However: No Tab key-pressed or key-released events are received by the key event listener. This is because the focus subsystem consumes focus traversal keys, such as Tab and Shift Tab. See: http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html To solve this, apply the following to the component that is firing the

Intercepting Tab key press to manage focus switching manually

帅比萌擦擦* 提交于 2019-11-29 04:53:47
I want to intercept Tab key press in my main window to prevent Qt from switching focus. Here's what I've tried so far: bool CMainWindow::event(QEvent * e) { if (e && e->type() == QEvent::KeyPress) { QKeyEvent * keyEvent = dynamic_cast<QKeyEvent*>(e); if (keyEvent && keyEvent->key() == Qt::Key_Tab) return true; } return QMainWindow::event(e); } This doesn't work, event isn't called when I press Tab . How to achieve what I want? The most elegant way I found to avoid focus change is to reimplement in your class derived from QWidget the method bool focusNextPrevChild(bool next) and simply return

emulate media key press on Mac

北城余情 提交于 2019-11-29 04:51:24
Is there a way to emulate key presses of the media keys (volume up/down, play, pause, prev, next) on common Apple notebooks? How? That took some time and many hacks (trying around with ctypes, the IOKit native interface, Quartz and/or Cocoa). This seems like an easy solution now: #!/usr/bin/python import Quartz # NSEvent.h NSSystemDefined = 14 # hidsystem/ev_keymap.h NX_KEYTYPE_SOUND_UP = 0 NX_KEYTYPE_SOUND_DOWN = 1 NX_KEYTYPE_PLAY = 16 NX_KEYTYPE_NEXT = 17 NX_KEYTYPE_PREVIOUS = 18 NX_KEYTYPE_FAST = 19 NX_KEYTYPE_REWIND = 20 def HIDPostAuxKey(key): def doKey(down): ev = Quartz.NSEvent