keyevent

Call a function that requires a KeyEvent parameter

老子叫甜甜 提交于 2020-01-06 21:59:44
问题 I would like to call this java function in another function. How can I manualy fire a KeyEvent? private void chooseItemByKey(KeyEvent event) I tried chooseItemByKey(new KeyEvent(null, null, null, null, null, KeyCode.DOWN, false, false, false, false)); to fire a KeyCode "Down" but my JRE told me there's a Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: argument type mismatch The method needs the KeyEvent because I trigger it also by a key, but I need to

Java KeyPress arrow keys triggers numpad keys

时光毁灭记忆、已成空白 提交于 2020-01-03 18:48:09
问题 When using Robot.keyPress for the KeyEvent VK_UP , the numpad key is triggered rather than the normal arrow key. I am trying to write a keyboard emulator that can be used for games etc. Testing with TrackMania I notice that it does not trigger the normal key, but the key on the numpad. How can I trigger the normal keys using keyPress? Checking the API, it is supposed to be the non-numpad arrow key. Which it isnt. Robot r = new Robot(); r.keyPress(KeyEvent.VK_UP); This will generate the numpad

Generate KeyEvent from QML

那年仲夏 提交于 2020-01-03 18:28:11
问题 How can I generate a KeyEvent? I have to show functionality on Keys.onPressed & events generated from my virtual keyboard. So can I fake generate key Events when my Virtual Keyboard events are generated? I could only find how to sendKeyEvents to QML from Qt, but I want to signal it from QML. 回答1: You can't directly in QML. What you can do is expose to your QML Virtual keyboard a custom Qt object that emits key signals when you want (e.g. by calling a method YourCustomKeySignalGenerator:

Listen Webview Key Events from software keyboard in Android Activity

我们两清 提交于 2020-01-03 15:34:28
问题 Is it possible to handle software keyboard events from a webview in a host Android application? For example, can my application's Activity listen the typed content in the search field of a webview displaying Google website? Considering the method described below this would be possible if I overwrite it returning true, but unfortunatelly I was not able to do it. Any ideas? public boolean shouldOverrideKeyEvent (WebView view, KeyEvent event) Added in API level 1 Give the host application a

How to use VK_UP or VK_DOWN to move to the previous or next Textfield?

别来无恙 提交于 2020-01-03 05:50:08
问题 I want to use the VK_UP or VK_DOWN to move the focus, so it can go to the previous or next textfield. How can i do that ? I tried using this, but it didnt work. private void passwordTFKeyTyped(java.awt.event.KeyEvent evt) { char c = evt.getKeyChar(); if (c == KeyEvent.VK_UP) { usernameTF.grabFocus(); } } So i tried adding 'System.out.println(c)' and the result given is empty (empty doesnt mean empty string like "" or null), its more like the UP Key isnt working. Thank you so much. 回答1:

CKEditor key event not updating text properly

南笙酒味 提交于 2020-01-02 07:19:21
问题 I have the following code to automatically update the content inside a div when the user types it inside a CKEditor textarea: CKEDITOR.instances.editor.on("key", function(e) { var preview = document.getElementById('some-div'); preview.innerHTML = CKEDITOR.instances.editor.getData(); }); The problem is that if I type in "Hello world", in the div it appears "Hello worl" and the "d" doesn't appear until another key is pressed. And I would want the same content in both places. Thanks in advance!

Override VK_Tab Focus action

假装没事ソ 提交于 2020-01-02 07:04:54
问题 Good Day! I am tying to add keyevent listener to jTextField so that if the user pressed the tab key, the caret position will go to the end of the text inside the jtextField, here is my code: private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { if(evt.getKeyCode()==KeyEvent.VK_TAB){ evt.consume(); jTextField1.setCaretPosition(jTextField1.getText().length()); } } But it doesn't work. How can i make this happen? 回答1: One way is to: First of all, don't use a KeyListener since this is

How can I capture mouseevents and keyevents using python in background on linux

风格不统一 提交于 2019-12-31 10:48:11
问题 I'd like to make a python script that can run in the background but print text when a mouseevent or keyevent happens. Are there any libraries/builtin functionality to achieve this? Or any system commands I can call to get this info? Being root is no issue. 回答1: I guess, you might use python bindings for evdev: http://packages.python.org/evdev/index.html. In tutorial they give an example for keyboard, but it should be similar for mouse events: >>> from evdev import InputDevice, categorize,

JavaFX KeyEvent returns KeyCode.UNDEFINED

爷,独闯天下 提交于 2019-12-30 18:27:13
问题 I created a simple JavaFX application that receives input from the user in a TextField. I attached the KeyTyped event from SceneBuilder to the controller. My function looks like this: @FXML private void keyTyped(KeyEvent event) { System.out.println(event.getCode().equals(KeyCode.ENTER)); } This function always prints out UNDEFINED when I type the enter key. Any ideas on how to fix this? Other letters I type seem to have the same problem as well. 回答1: KeyTyped is a special event. It doesn't

how to spoof arrow keys to my activity on android

雨燕双飞 提交于 2019-12-30 12:21:38
问题 I am trying to override the volume buttons to act as Up/Down arrow keys (i.e. they should move focus around on all of my activities focus-able Views.) To do so I am overriding my activities dispatchKeyEvent() method note that I also tried onKeyDown() but some portion of my volume key events was still going thru to the system, my device has audible feedback when you change the volume. I could still hear the beep but the volume was not actually being changed. Switching to dispatchKeyEvent()