Questions tagged [onkeydown]

This event is triggered when when the user is pressing a key or holding down a key.

520 questions
1449
votes
31 answers

Trigger a button click with JavaScript on the Enter key in a text box

I have one text input and one button (see below). How can I use JavaScript to trigger the button's click event when the Enter key is pressed inside the text box? There is already a different submit button on my current page, so I can't simply make…
kdenney
  • 18,343
  • 4
  • 31
  • 27
84
votes
5 answers

How to capture a backspace on the onkeydown event

I have a function that is triggered by the onkeydown event of a textbox. How can I tell if the user has hit either the backspace key or the del key?
Raphael
  • 7,972
  • 14
  • 62
  • 83
42
votes
3 answers

Using jQuery to listen to keydown event

I want to detect when the enter key is pressed, on HTML that will be injected dynamically. To simply detect when the enter key is pressed, I can do: $('#textfield').keydown(function (e){ if(e.keyCode == 13){ console.log('Enter was…
Don P
  • 60,113
  • 114
  • 300
  • 432
34
votes
6 answers

Fragment activity catch onKeyDown and use in fragment

I have Fragment activity with pager: List fragments = new Vector(); fragments.add(Fragment.instantiate(this, PastEventListFragment.class.getName(),bundle)); fragments.add(Fragment.instantiate(this,…
FlorinD
  • 481
  • 2
  • 8
  • 25
24
votes
6 answers

onKeyListener not working on virtual keyboard

I don't understand why this piece of code is not working. Only backspace and return key are detected. Listener doesn't fire for any other key. My device is Nexus One. I tried to override activity's OnKeyDown method and that's even worse. The only…
bobetko
  • 5,019
  • 14
  • 58
  • 85
20
votes
2 answers

onKeyDown in a service? (Global Hot Keys)

What I'm basically trying to achieve is custom global hot keys or in other words 'things will happen when I push certain buttons no matter which program is currently on top'. I assume a service is needed. I have a quick and dirty test that just…
Fizz
  • 201
  • 1
  • 2
  • 3
20
votes
6 answers

onKeyListener not working with soft keyboard (Android)

I am using onKeyListener to get the onKey events. It works fine with the normal keyboard. But it does not work with soft keyboard. I am only able to get onKey events for numerics and not alphabets. Is there any workaround to solve this? Any kind of…
user238974
19
votes
6 answers

Detect Ctrl + C and Ctrl + V in an input from browsers

I am using the direct following and I do not detect the copy and paste with the keys inside the input, would someone know how? Thank you! export class OnlyNumberDirective { // Allow decimal numbers. The \, is only allowed once to occur …
Mario Ramos García
  • 755
  • 3
  • 8
  • 20
19
votes
4 answers

WPF: OnKeyDown() not being called for space key in control derived from WPF TextBox

In a WPF application, I have a control that I have derived from TextBox like this: public class SelectableTextBlock : TextBox { protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); e.Handled = false; …
Ergwun
  • 12,579
  • 7
  • 56
  • 83
17
votes
3 answers

Detection of Backspace on KeyDown

I am working on a silverlight web app. It interacts with a module that sends SMS's. I want to limit the text to 160 and show a counter. I did it like this: public partial class SendSMSView { public SendSMSView() { …
whizzyifti
  • 259
  • 1
  • 2
  • 9
16
votes
2 answers

Upgraded to AppCompat v22.1.0 and now onKeyDown and onKeyUp are not triggered when menu key is pressed

I've just upgraded my app to use the newly released v22.1.0 AppCompat and now onKeyDown and onKeyUp are not triggered when menu key is pressed. The other keys correctly trigger onKeyDown and onKeyUp, but when i press the menu key nothing happens. If…
Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
16
votes
3 answers

AutoCompleteTextView detect when selected entry from list edited by user

I have an AutoCompleteTextView I use to select an item from a long list. The user should only be able to select a predetermined item from the list. They should not be able to enter their own item. The way I check to make sure they submit only an…
Rynardt
  • 5,547
  • 7
  • 31
  • 43
13
votes
8 answers

onKeyDown() issue

I would like to create a photo/video capture application. I have created a CaptureView class which extends SurfaceView and placed it in the main form. The main form's activity has onCreateOptionsMenu() method which creates a menu. The menu worked…
Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286
12
votes
2 answers

How to detect if the Up button was pressed

In my activity the action bar shows only the left arrow and the title of the activity. When I press the left arrow the activity goes back to the previous activity, but no event is registered in the onKeyUp, OnkeyDown and OnBackPressed methods. But…
Zvi
  • 2,354
  • 2
  • 26
  • 37
12
votes
8 answers

How to force "enter key" to act as "tab key" using javascript?

I'm working on a site that is full of forms to be filled and I it's required that when escape button is pressed focus move to the next input control, just as pressing "tab" do. I found code to move focus when keypressed is 13 but this need to take…
Heba Gomaah
  • 1,145
  • 4
  • 11
  • 16
1
2 3
34 35