keydown

silverlight keydown event doesn't fire for arrow keys

I have a canvas inside a scrollview. I attached a keydown event handler to the scrollview. For most keys, the handler gets called. However, for the arrow keys, the handler does not get called. Instead, the scrollview gets scrolled in the appropriate direction. I also attached a keyup handler to the scrollview and the keyup does get ca...

Control key plus mouse wheel.

What's the better way to handle the ctrl + mouse wheel in C#? I've figured out how to handle the MouseWheel event but how to know that the ctrl key is being pressed too? Thanks in advance. ...

How can I capture KeyDown event on a WPF Page or UserControl object?

I have a Page with a UserControl on it. If the user presses Esc while anywhere on Page I want to handle. I thought this would be as easy as hooking up the PreviewKeyDown event, testing for the Esc key, and then handling it. However, when I placed I breakpoint in the event handler I found it was never getting called. I thought perhaps...

Combobox KeyDown event handler firing multiple times

In VB.NET, I have a Combobox on a WinForm form. The form allows the user to type in a query to be searched. When the user hits the Enter key, a query is performed against the database and the results are returned as a DataTable. The DataTable is then bound to the Combobox and the user can select the option that they are looking for. ...

Why does contentEditable element reject the Enter key?

Hi, I'm using an application that embeds IE control to show content. I change that content to contain a <div contentEditable="True">Hello World</div> element. This works well and I can edit the content of this div, but pressing Enter is rejected with a beep. When I add a textarea element to that page the Enter key works and I can add l...

Textarea lags after registering `keydown` events using Javascript

How does one go about attaching a bunch of code to an onkeydown event, but keep entering text into a textarea fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably. EDIT: I should add (can't believe I forgot!) that this doesn't affect desktop browsers. It's mainly an issue with iPhone Safa...

How to determine if a keydown event occurs on a printable character?

We are trying to prevent users from typing beyond the maximum characters our DB allows for text area fields in our web app. Once they have reached the max length allowed in the text area we would still like to allow them to hit keys that are non-printing for example: Tab, backspace, ctrl+s, etc. I'm wondering if there is a simple way t...

Adding event handler to an iframe using JQuery

I want to assign a keydown event handler to an iframe. Something similar to the pure JS: document.getElementById('iframe_id').contentWindow.addEventListener('keydown',funcName, true); I tried: $(document.getElementById('iframe_id').contentWindow).keydown( function() { // my func }); But it does not work.. Please help! ...

Delphi 2009 OnKeyDown does not trap as Delphi 2007 does

Hello, I have this code procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var begin if not (Key in [Ord('0')..Ord('9')]) then Key := 0; end; and it worked fine with Delphi 2007. When I upgraded to Delphi 2009 and I try to press any letter it is accepted and the Key := 0 does not trap the input? ...

Handling key events on WebBrowser control

I am using the WebBrowser control in a C# application and want to handle all key events while the WebBrowser has the focus, regardless what individual content element (input field, link, etc.) is focused. I tried to simply add an event handler to browser controls KeyDown event, but this does not work. I don't want to explicitly hook a ...

How do I convert a "Keys" enum value to an "int" character in C#?

This seems like something that should be easy, but I am having a tough time figuring out what needs to happen here. In the "KeyDown" eventhandler, if the "e.KeyValue" is a number, I want to treat it as a number and store it as an int. So, if I hit "8" on the number pad, I don't want "Numpad8" I want the int value 8 that I can add or su...

How can I capture the keystroke that triggers "CellEndEdit" on a DataGridView in C#?

I have a DataGridView that is set to EditOnF2. I do some special processing of data in the CellEndEdit eventhandler that sets the value of the cell. I still want the functionality of the EditOnKeystrokeOrF2 of reverting to the original value when the Esc key is pressed. Unfortunately, at the CellEndEdit eventhandler, I don't see a way...

Making a WPF TabControl ignore Ctrl+Tab

I'm writing an app that uses the "tabbed browsing" metaphor, with a TabControl the full size of the window, and other stuff inside the tabs. Sometimes those tabs will themselves contain other TabControls. (Tabs inside tabs can be confusing, so I'll re-style the inner TabControl so it doesn't look like a TabControl. I'll probably style i...

Capturing Keyboard strokes in C#

HI, I have the following problem- the following text is in a rich text box . The world is [[wonderful]] today . If the user provides two brackets before and afer a word, as in the case of wonderful , the word in brackets, in this case, wonderful shall change to a link, ( with a green colour ) . I am having problems in getting the seq...

Silverlight textbox overrides

I'm trying to get a textbox keydown event to trap the backspace key down event. I have that working by adding a Class that overrides the textbox. What i don't know how to do is have that communicate with the class where the textbox is in the user control. When a user types in the text box... say abcd or backspace, i need to update so...

C# - Tetris clone - Can't get block to respond properly to arrow key combinations

I'm working on programming a Tetris game in Visual C# 2005. This is the most extensive program I have designed yet. I create a shape class and a block class to control the location, movement, and display of the different Tetris pieces. I have moveDown(), moveLeft(), and moveRight() functions for each shape (and corresponding canMoveDown...

Detect F5 being pressed and Refresh

I have a webform and i want to detect if F5 button was pressed or if the page was refreshed. I know about postback but it is not what i'm looking for. I have a gridview that loads in a modal popup when a button is clicked and a parameter's value is set for the gridview. When refresh is hit and if the modal popup button was previously cli...

keydown in flex Flex

I have an small application in flex in which I have defined 2 canvases. On one of them I added controls and the other one is used to draw something and no controls are added: <mx:Canvas x="0" y="80" width="100%" height="520%" id="Canvas1"/> <mx:Canvas x="0" y="0" width="100%" height="80" id="Canvas2"/> I add an keydown event handled t...

How do I detect the 'delete' key in my Field subclass?

I'm trying to detect and override the Delete key on the Blackberry keyboard. For some reason, it never makes it inside my case statement as when it hits that point: Keypad.key(keycode) == 8 Keypad.KEY_DELETE == 127 What's my error? public class MyField extends ListField implements KeyListener { // ... /** Implementation of KeyListen...

How do I capture keystrokes in a Silverlight application?

I am trying to capture any keystroke that happens inside my Silverlight 2 application. There are not any input fields, I'm writing a game, and need to know which of the arrow keys are being pressed. My best guesses at how to capture these through an event handler are unsuccessful. Any recommendations? ...