Questions tagged [keyevent]

An event that is triggered when a key is pressed,released or remains pressed on a keyboard input device.

A KeyEvent is an event that is triggered when a key is pressed, released or remains pressed on a keyboard input device. The event can contain:

  • info about particular key that was pressed/released
  • how long the key was pressed
  • whether any modifier keys were also pressed (such as Ctrl or Alt).
  • type of event - press, release, other (for example character was typed, regardless whether key was pressed or released)

Some platforms/keyboards may generate auto-repeat key events - same character is typed repeatedly while key remain pressed

1258 questions
674
votes
10 answers

How to detect escape key press with pure JS or jQuery?

Possible Duplicate: Which keycode for escape key with jQuery How to detect escape key press in IE, Firefox and Chrome? Below code works in IE and alerts 27, but in Firefox it alerts 0 $('body').keypress(function(e){ alert(e.which); …
Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236
85
votes
11 answers

keyCode on android is always 229

On my Samsung Galaxy tab 4 (Android 4.4.2, Chrome: 49.0.2623.105) I ran into a situation where the keyCode is always 229. I've setup a simple test for two situation
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
76
votes
20 answers

jquery how to catch enter key and change event to tab

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…
payling
  • 2,466
  • 5
  • 33
  • 44
66
votes
9 answers

android.view.View$OnUnhandledKeyEventListener

I am new to Android Studio and I don't get why my toolbar isn't shown as described by https://developer.android.com/training/appbar/setting-up I know there are already some other questions like mine on stackoverflow but they don't work at my…
David Schmidt
  • 758
  • 1
  • 5
  • 7
38
votes
4 answers

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

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…
Brian
  • 789
  • 1
  • 7
  • 14
33
votes
3 answers

KeyEventCompat not supported at build

My project is currently using but seems I have moved to api level 26 - revision 26.0.2, I am struggling to find the symbol KeyEventCompat import android.support.v4.view.KeyEventCompat; I try to figure out using v7 but it's not working. Any idea on…
Seb
  • 2,929
  • 4
  • 30
  • 73
33
votes
4 answers

Android - Get keyboard key press

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)…
Bemipefe
  • 1,397
  • 4
  • 17
  • 30
30
votes
2 answers

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

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…
stackoverflow
  • 18,348
  • 50
  • 129
  • 196
30
votes
4 answers

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

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…
Bohn
  • 26,091
  • 61
  • 167
  • 254
30
votes
3 answers

When CMD key is kept pressed, keyup is not triggered for any other key

I am developing an application where I need to do some post-processing when the user presses CMD+LEFT on a particular text-box. I need to do this after the browser's default functionality (i.e. after it takes the caret to first position in current…
techfoobar
  • 65,616
  • 14
  • 114
  • 135
29
votes
2 answers

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

I need to simulate "Enter" key event in Qt. How can I do this?
Andersson83
  • 441
  • 1
  • 8
  • 12
23
votes
2 answers

Jquery Run code 2 seconds after last keypress

I am working on a auto search function for a site. It uses ajax to query an api. At the moment after 3 characters are entered it will search on every key press. What I want is Case1: User enters tes 2 seconds pass search performed Case2:…
Hailwood
  • 89,623
  • 107
  • 270
  • 423
21
votes
6 answers

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

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…
s.d
  • 4,017
  • 5
  • 35
  • 65
21
votes
2 answers

Can't fire keypress event when press delete key

I'm finding that the delete key doesn't fire the keypress event in Chrome, while other keys work. The problem doesn't occur in Firefox, just in Chrome, why? Here is my code: document.addEventListener('keypress', function (e) { …
qiu8310
  • 237
  • 1
  • 2
  • 8
20
votes
4 answers

How to use Key Bindings instead of Key Listeners

I'm using KeyListeners in my code (game or otherwise) as the way for my on-screen objects to react to user key input. Here is my code: public class MyGame extends JFrame { static int up = KeyEvent.VK_UP; static int right =…
user1803551
  • 12,965
  • 5
  • 47
  • 74
1
2 3
83 84