This event is triggered when when the user is pressing a key or holding down a key.
Questions tagged [onkeydown]
520 questions
6
votes
2 answers
How to trigger button by pressing enter in Angular 9
Is it possible to trigger my "Add" button by pressing enter on the keyboard?
////
This is the last div in the form, for the third gap:
6
votes
3 answers
Fake KeyEvent doesn't work *exactly* like "real" button. Why?
I am trying to invoke my main activity's onKeyDown() with KEYCODE_BACK, so that it behaves as if I pressed the 'back' button myself. I do that using the following code:
KeyEvent goBackDown = new…

srf
- 2,410
- 4
- 28
- 41
6
votes
0 answers
Listen for power button long press from inside a service
I was able to override the long pressed power button from inside an activity. But Iwanted it inside a service. Is it possible to do this listening for key events inside a service.
Here is the code within the activity
@Override
public boolean…

ik024
- 3,566
- 7
- 38
- 61
6
votes
2 answers
Capture keys.TAB on KeyDown
I am trying to capture TAB keypress on Keydown Event.
I can see another post on How to fire an event when the tab key is pressed in a textbox?
However, On the above link, posted solution is not working for me which I mentioned below.
Private Sub…

Kartik Goyal
- 376
- 1
- 6
- 15
6
votes
1 answer
override existing onkeydown function
My extensions go through every input entered on an on any website that is loaded.
What I do is I consider every onkeydown and manipulate it if it has some value.
my background js file contains the following:
document.onkeydown = returnKey;…

Assaf Vilmovski
- 89
- 1
- 9
6
votes
3 answers
Android onKeyDown not catching Dpad center and enter key presses
Doing a simple override in my base activity of onKeyDown, I'm able to capture all key presses except those of the enter and dpad center buttons (as determined via breakpoint). I've no clue as to why - can anyone shed some light on the…

user1403565
- 153
- 2
- 8
6
votes
2 answers
Why are onkeyup events not firing in Javascript game
I have the beginnings of a 2d Javascript game - at the moment the player can drive a triangle around the screen using the arrow keys.
The problem is that sometimes the triangle will get stuck rotating in one direction or moving forward until the…

RobotEyes
- 4,929
- 6
- 42
- 57
5
votes
0 answers
React Input onKeyDown/onKeyUp Android Chrome
The issue I am running into is I have a React App with a form with Input elements that I have a need to detect if the Enter Key or , has been pressed. It is working fine on desktop chrome but Android chrome (Samsung Note 9). First the mobile…

TagmanSr
- 51
- 2
5
votes
2 answers
Dialog shown twice when back button pressed
In code the dialog is shown two times when i press the back button. Can anyone please tell me how to get the dialog only once?
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
…

akhil2003in
- 71
- 5
5
votes
1 answer
React Component passes Proxy object instead of Event object to the handler function
I have prepared the following React Component (React version 1.5.2):
var QuickSearch = React.createClass({
searchHandler: function(){
this.props.parent.props.dataSource.search = this.refs.SearchInput.value;
…

PiWo
- 590
- 2
- 8
- 17
5
votes
1 answer
Loop a function while key is pressed
I'm trying to move a div up and down using two keys in Javascript. The idea is that while a certain key is depressed, a function loops and adds to the div's 'top' style value each time. The basic function works, but I can't get it to loop and I…

Blando
- 55
- 1
- 1
- 5
5
votes
3 answers
How to move an element via arrow keys continuously/smoothly?
I'm making a primitive game with Javascipt for fun. I have set up functions to move my character around when the arrow keys are pressed as follows:
document.getElementById("character").style.top = 0;
document.getElementById("character").style.left…

Eric David Sartor
- 597
- 2
- 8
- 22
5
votes
1 answer
Android: How to call MediaController fast forward and rewind using KeyEvents
Hi I am using mediacontroller to control my mediaplayer, I want to control using keyEvents rather than touchevents, I am using the code below to do that, but only Play/Pause is working, where as KEYCODE_MEDIA_FAST_FORWARD and KEYCODE_MEDIA_REWIND…

bala
- 168
- 1
- 8
5
votes
1 answer
How to use different onKeyDown in fragment of a same activity
I want to use different onKeyDown or onKeyUp in different fragment,but the method is written in the activity.So I want to find a way to write different onKeyDown.

Marshal Chen
- 1,985
- 4
- 24
- 35
5
votes
1 answer
Android onkey - dispatchKeyEvent not firing
well, I've tried all the solutions I could find on stackoverflow and in other places, but the end result hasn't changed one bit: the only key that triggers the onKey event or the dispatchKeyEvent is the enter key on the virtual keyboard, and only if…

slack ewix
- 51
- 1
- 3