Questions tagged [keyboard-events]

An event that is triggered when a Key is pressed on a keyboard input device

A KeyboardEvent is an event that is triggered when a Key is pressed on a keyboard input device. The event will contain information relating to the particular key that was pressed, how long the key was pressed for, and whether any modifier keys were also pressed (such as Ctrl or Alt).

1973 questions
773
votes
19 answers

How to detect pressing Enter on keyboard using jQuery?

I would like to detect whether the user has pressed Enter using jQuery. How is this possible? Does it require a plugin? EDIT: It looks like I need to use the keypress() method. I wanted to know if anyone knows if there are browser issues with that…
chris
  • 18,595
  • 28
  • 74
  • 88
521
votes
21 answers

Detecting arrow key presses in JavaScript

How do I detect when one of the arrow keys are pressed? I used this to find out: function checkKey(e) { var event = window.event ? window.event : e; console.log(event.keyCode) } Though it worked for every other key, it didn't for arrow keys…
mihsathe
  • 7,936
  • 9
  • 33
  • 53
138
votes
13 answers

Android Use Done button on Keyboard to click button

Ok in my app I have a field for the user to input a number. I have the field set to only accept numbers. When the user clicks on the field it brings up the keyboard. On the keyboard (on ICS) there is a done button. I would like for the done button…
mpeerman
  • 1,950
  • 2
  • 15
  • 16
112
votes
5 answers

How can I programmatically generate keypress events in C#?

How can I programmatically create an event that would simulate a key being pressed on the keyboard?
Dan Vogel
  • 3,608
  • 7
  • 38
  • 53
103
votes
11 answers

How to generate keyboard events?

short summary: I am trying to create a program that will send keyboard events to the computer that for all purposes the simulated events should be treated as actual keystrokes on the keyboard. original post: I am looking for a way to generate…
Inbar Rose
  • 35,719
  • 22
  • 80
  • 120
82
votes
5 answers

Firing a Keyboard Event in Safari, using JavaScript

I'm trying to simulate a keyboard event in Safari using JavaScript. I have tried this: var event = document.createEvent("KeyboardEvent"); event.initKeyboardEvent("keypress", true, true, null, false, false, false, false, 115, 0); ...and also…
Steve Harrison
  • 103,209
  • 15
  • 83
  • 71
78
votes
13 answers

Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser

I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3. Any…
cllpse
  • 20,270
  • 35
  • 127
  • 168
49
votes
3 answers

Hitting Tab in Visual Studio selects block instead of adding indentation

I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly: When the cursor…
46
votes
1 answer

How to simulate typing in input field using jQuery?

What I want is to simulate typing in field using javascript. I have the following code: var press = jQuery.Event("keydown"); press.ctrlKey = false; press.which = 65; $("#test").trigger(press); But when I load the page, the #test input field…
45
votes
7 answers

Android EditText, soft keyboard show/hide event?

Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?
shkim
  • 1,163
  • 3
  • 16
  • 24
42
votes
4 answers

UISearchbar keyboard search button Action

I'm using UISearchBar when I input text on UISearchBar the keyboard shows. At that time, keyboard return key is "Search". I want to implement event when I press the keyboard search button. How can I implement the action? On UITextField it has…
Chenggong Jin
  • 511
  • 1
  • 4
  • 9
41
votes
9 answers

How to detect if the pressed key will produce a character inside an text-box?

I have a regular text-box: I use jQuery to handle key-related events: $("input:text").keydown(function() { // keydown code }).keypress(function() { // keypress code }).keyup(function() { // keyup code }); The…
Šime Vidas
  • 163,768
  • 59
  • 261
  • 366
35
votes
1 answer

Accessing Keys from Linux Input Device

What I am trying to do So, I have been trying to access keyboard input in Linux. Specifically, I need to be able to access modifier key presses without other keys being pressed. Furthermore, I want to be able to do this without an X system…
Senkwich
  • 952
  • 1
  • 7
  • 16
34
votes
2 answers

Capture Control-C in Python

I want to know if it's possible to catch a Control-C in python in the following manner: if input != contr-c: #DO THINGS else: #quit I've read up on stuff with try and except KeyboardInterrupt but they're not working for me.
pauliwago
  • 5,359
  • 10
  • 36
  • 48
28
votes
6 answers

KeyboardEvent in Chrome, keyCode is 0

I am trying to set keyCode on dispatched event object . On button click, event is raised on textbox control to simulating keydown event. Event is raised successfully, but keyCode is 0. I need to send event object with correct keyCode to…
Andrija
  • 12,383
  • 17
  • 51
  • 75
1
2 3
99 100