keyevent

Read Keyboard events in Android WebView

◇◆丶佛笑我妖孽 提交于 2019-11-29 01:45:35
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); return super.onKeyUp(keyCode, event); } @Override // Listener is initialized in the constructor public

How can I simulate user interaction (key press event) in Qt?

那年仲夏 提交于 2019-11-29 01:09:25
I need to simulate "Enter" key event in Qt. How can I do this? QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter); QCoreApplication::postEvent (receiver, event) dnlcrl The correct answer might be this: QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QCoreApplication::postEvent (receiver, event); in fact there are no matching function for call to QtKeyEvent::QtKeyEvent(Type type, int key) but there is: QtKeyEvent::QtKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers) 来源: https://stackoverflow.com/questions/2035310/how-can-i

Android - Get keyboard key press

早过忘川 提交于 2019-11-28 18:17:55
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) Override the onKeyUp(int keyCode, KeyEvent event) View method. This not work at all neither if I set my

Check Keyboard Input Winforms

六月ゝ 毕业季﹏ 提交于 2019-11-28 14:50:30
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. Since you usually want to perform an action immediately after pressing a key, usually using a KeyDown event is enough. But in some cases I suppose

Java KeyListener keyPressed method fires too fast

假装没事ソ 提交于 2019-11-28 12:53:51
If you use the java KeyListener class you know that if you hold down a key keyPressed will fire one KeyEvent , and then about half a second later will fire the same key many times very very fast. I would like to know if there is a way to keep the KeyEvents from firing too fast. I would like them to be at a nice constant rate of about once every 500 ms. You can, but the trick is to not slow down the firing of events, but to slow down how fast you process them: KeyListener kl = new KeyListener() { private long lastPressProcessed = 0; @Override public void keyPressed(KeyEvent e) { if(System

Key Events in TabActivities?

允我心安 提交于 2019-11-28 08:49:23
I have a TabActivity and want to catch and handle presses of HOME and BACK. Where do I need to catch these events? In my subclass of TabActivity I implement the following: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { // Code handling } return super.onKeyDown(keyCode, event); } Didn't work. So I placed a breakpoint on the switch statement line. But this function never gets called, whether I press volume up/down, menu, home, or back. Where do I need to catch these KeyEvents? Steve Zeng It turns out to be pretty easy. Add the following code to your child

Move image using keyboard - Java

人盡茶涼 提交于 2019-11-28 08:20:51
问题 I wanted to move my image using keyboard arrow keys. when I pressed the arrow keys it moves accordingly to the direction. However, I need to click on the image before able to move it. May I know how to edit the code such that I do not need to click on the image before able to move it? I would also like to know how to make the image appear from the left once it reaches right and vice versa. My codes are : Collect.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent ke) { if(ke

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

て烟熏妆下的殇ゞ 提交于 2019-11-28 02:28:23
问题 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? 回答1: 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

Why trigger F11 press event doesn't work?

早过忘川 提交于 2019-11-27 23:46:23
I just read this question: Full Screen Page by pressing button instead of F11 The op asked to replace F11 with other hot keys, so I'm wondering that maybe I can simulate press F11 to get things work. I learned that I can use trigger in JQuery to simulate key press event, so I do something like this: $("body").keyup(function (e) { alert(e.which); }); var e = $.Event("keyup"); e.which = 122; // # Key code of F11 $("body").trigger(e); When I run this, I got the alert says 122, but it seems that it doesn't give the hoped result. Is there a restriction there? I made a fiddle here: http://jsfiddle

KeyTypedEvent KeyEvent's KeyCode is always 0?

那年仲夏 提交于 2019-11-27 23:34:30
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 that my keylistener does work. When I build and run my application, I realized that the output always