keyevent

emulate media key press on Mac

落爺英雄遲暮 提交于 2019-12-18 04:19:29
问题 Is there a way to emulate key presses of the media keys (volume up/down, play, pause, prev, next) on common Apple notebooks? How? 回答1: 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

Read Keyboard events in Android WebView

我是研究僧i 提交于 2019-12-18 03:23:14
问题 I'm trying to listen to key events in android web view. Example when user is filling a form, I should receive the key events. This is my WebView code public class MyWebView extends WebView implements OnKeyListener { ..... @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i("PcWebView", "onKeyDown keyCode=" + keyCode); return super.onKeyDown(keyCode, event); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log.i("PcWebView", "onKeyUp keyCode=" + keyCode);

Read Keyboard events in Android WebView

雨燕双飞 提交于 2019-12-18 03:23:08
问题 I'm trying to listen to key events in android web view. Example when user is filling a form, I should receive the key events. This is my WebView code public class MyWebView extends WebView implements OnKeyListener { ..... @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i("PcWebView", "onKeyDown keyCode=" + keyCode); return super.onKeyDown(keyCode, event); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { Log.i("PcWebView", "onKeyUp keyCode=" + keyCode);

KeyTypedEvent KeyEvent's KeyCode is always 0?

吃可爱长大的小学妹 提交于 2019-12-17 16:34:42
问题 I have a Java Swing application in the NetBeans IDE. I made a form and attached a KeyListener to my various controls as such: jButton1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { keyTypedEvent(evt); } }); and keyTypedEvent is defined as such: private void keyTypedEvent(java.awt.event.KeyEvent evt) { System.out.println(evt); appendDisplay(String.valueOf(evt.getKeyChar())); } I added a println to the evt to see what happens and to verify

How do I capture Keys.F1 regardless of the focused control on a form?

社会主义新天地 提交于 2019-12-17 07:29:17
问题 I used KeyDown event and some simple code like if (e.KeyCode == Keys.F1) to capture F1 is pressed on a form BUT if there are some text boxes on the form or if there are some spreadsheets with Dock Fill on the form then the code above gets useless and does nothing. But I want to do something when user presses F1 on this form. so how do we capture a specific keydown event like F1 on the whole form..and I do not want to go to the route that capture the KeyDown of all other controls on the form

How do I capture Keys.F1 regardless of the focused control on a form?

爷,独闯天下 提交于 2019-12-17 07:26:11
问题 I used KeyDown event and some simple code like if (e.KeyCode == Keys.F1) to capture F1 is pressed on a form BUT if there are some text boxes on the form or if there are some spreadsheets with Dock Fill on the form then the code above gets useless and does nothing. But I want to do something when user presses F1 on this form. so how do we capture a specific keydown event like F1 on the whole form..and I do not want to go to the route that capture the KeyDown of all other controls on the form

Is it possible to create an Android Service that listens for hardware key presses?

我只是一个虾纸丫 提交于 2019-12-17 07:12:39
问题 I'd like to run an Android background service that will act as a keylistener from the home screen or when the phone is asleep. Is this possible? From semi-related examples online, I put together the following service, but get the error, "onKeyDown is undefined for the type Service". Does this mean it can't be done without rewriting Launcher, or is there something obvious I'm missing? public class ServiceName extends Service { @Override public void onCreate() { //Stuff } public IBinder onBind

Is it possible to create an Android Service that listens for hardware key presses?

六眼飞鱼酱① 提交于 2019-12-17 07:12:06
问题 I'd like to run an Android background service that will act as a keylistener from the home screen or when the phone is asleep. Is this possible? From semi-related examples online, I put together the following service, but get the error, "onKeyDown is undefined for the type Service". Does this mean it can't be done without rewriting Launcher, or is there something obvious I'm missing? public class ServiceName extends Service { @Override public void onCreate() { //Stuff } public IBinder onBind

jquery how to catch enter key and change event to tab

空扰寡人 提交于 2019-12-17 06:32:35
问题 I want a jquery solution, I must be close, what needs to be done? $('html').bind('keypress', function(e) { if(e.keyCode == 13) { return e.keyCode = 9; //set event key to tab } }); I can return false and it prevents the enter key from being pressed, I thought I could just change the keyCode to 9 to make it tab but it doesn't appear to work. I've got to be close, what's going on? 回答1: Here is a solution : $('input').on("keypress", function(e) { /* ENTER PRESSED*/ if (e.keyCode == 13) { /* FOCUS

How can a KeyListener detect key combinations (e.g., ALT + 1 + 1)

二次信任 提交于 2019-12-17 03:41:42
问题 How can I let my custom KeyListener listen for combinations of ALT (or CTRL for that matter) + more than one other key? Assume I have 11 different actions I want the application to do, depending on a combination of keys pressed. ALT + 0 - ALT + 9 obviously don't pose any problems, whereas for ALT + 1 + 0 (or "ALT+10" as it could be described in a Help file or similar) I cannot find a good solution anywhere on the web (or in my head). I'm not convinced that this solution with a timer is the