keypress

Get a String from a collection of keys presses retrieved using Raw Input API

∥☆過路亽.° 提交于 2019-12-03 15:41:17
I am using the Raw Input API to get a collection of key presses from a keyboard (actually, a magnetic stripe card reader that emulates a keyboard). Here are a couple of code excerpts so you can have an idea of how I'm getting the keys. [StructLayout(LayoutKind.Sequential)] internal struct RAWKEYBOARD { [MarshalAs(UnmanagedType.U2)] public ushort MakeCode; [MarshalAs(UnmanagedType.U2)] public ushort Flags; [MarshalAs(UnmanagedType.U2)] public ushort Reserved; [MarshalAs(UnmanagedType.U2)] public ushort VKey; [MarshalAs(UnmanagedType.U4)] public uint Message; [MarshalAs(UnmanagedType.U4)] public

AngularJS submit on blur and blur on keypress

倖福魔咒の 提交于 2019-12-03 13:58:54
I want to submit some data to the server when a input field is blurred. The User should also be able to blur the input field by pressing enter. Unfortunately this results in the following: $rootScope:inprog: $apply already in progress error . Plunkr - thanks in advance! Here's what's happening: You press enter ng-keydown triggers (digest begins) You call target.blur() ng-blur triggers and attempts to start another digest cycle Angular complains The blur is executed synchronously and immediately triggers the handler without finishing the first digest. In my opinion, this is not a problem with

How to watch for a keypress combination in Angularjs? [duplicate]

故事扮演 提交于 2019-12-03 13:38:44
问题 This question already has answers here : AngularJS - Multiple keypress at the same time (4 answers) Closed last year . I'm trying to get my controller to watch for a combination of keys. For argument's sake, let's say: up up down down left right left right b a. How can I get angular to look out for these regardless of where in the page the user currently is? 回答1: Looks like you can use the ng-keydown to do this. Here is a working plunker. For this sample, I just bound ng-keydown to <body> .

How do I simulate a Tab key press when Return is pressed in a WPF application?

不想你离开。 提交于 2019-12-03 11:20:21
In a WPF application, i have a window that has a lot of fields. When the user uses the TAB key after filling each field, windows understands that it moves on to the next. This is pretty know behavior. Now what I want to to, is make it simulate the TAB key, when in fact the RETURN gets hit. So in my WPF xaml I added imply KeyDown="userPressEnter" And in the code behind it: private void userPressEnter(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { e.Key = Key.Tab // THIS IS NOT WORKING } } Now, obviously this is not working. But what I don't know is, how DO I make this work? EDIT 1

jquery keypress() event get text

拜拜、爱过 提交于 2019-12-03 10:40:39
问题 I want a function to be run when a keypress occurs on a text box, so I have this code: $("input[x]").keypress(function() { DoX(); }) This is working fine, but in my function I want to do something based on the text value in the textbox var textValue = ("input[x]").val(); Now the problem here is that it lags behind by a key so if my text box says 'He' and I type an 'l', then I want my textValue to be 'Hel', but it is returning the previous value 'He' because presumably the character hasn't

jQuery: how to capture keypress key using live()

房东的猫 提交于 2019-12-03 10:20:24
问题 I need to capture a tab keypress event on some dynamic inputs, but the normal syntax using the keypress event doesn't seem to be catching the key code. $('input').live('keypress', function (e) { if ( e.which == 9 ) alert( 'Tab pressed' ); }); This seems to be catching 0 as the keypress when I go through the debugger in firebug no matter which key I press. 回答1: Try it with .keyCode instead of .which: $('input').live('keypress', function (e) { if ( e.keyCode == 9 ){ alert( 'Tab pressed' ); } })

Firing down arrow key press in a select box via javascript

我怕爱的太早我们不能终老 提交于 2019-12-03 08:38:13
For strange reasons I have to change the selected element in a dropdownbox not via e.selectedIndex, but via the simulation of mouse and keypress events. I tried the following: //e = the dropdown e.focus(); //my custom function to fire mouse events. This opens the dropdown. fireMouseEvent("mousedown", e); //firing the key press, tried it via keydown, keypress and keyup. Nothing works. var evt = e.ownerDocument.createEvent("KeyEvents"); evt.initKeyEvent("keydown", true, true, null, false, false, false, false, 40, 0); evt.initKeyEvent("keypress", true, true, null, false, false, false, false, 40,

Selenium-IDE: How to simulate non-printable keys (ENTER, ESC, Backspace)?

浪尽此生 提交于 2019-12-03 08:37:42
问题 What is the exact HTML code to simulate ENTER, ESC, BACKSPACE and DOWN in Selenium IDE 1.3.0? typeKeys didn't work nor did this: <tr> <td>keyDown</td> <td>id=zc_0_4_3-real</td> <td>10</td> </tr> <tr> <td>keyUp</td> <td>id=zc_0_4_3-real</td> <td>10</td> </tr> <tr> <td>keyPress</td> <td>id=zc_0_4_3-real</td> <td>10</td> </tr> 回答1: For example to submit a form by pressing enter, the only one I can figure out is: Command: keyPressAndWait Target: id=q [depends on your form of course] Value: \\13

Search datagridview on user keypress

对着背影说爱祢 提交于 2019-12-03 07:20:36
I'm trying to select the first row where the cell value starts with the same keychar the user pressed. That's the part that is giving me trouble. Here's how I'm handling the event ( updated with working solution ): private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e) { if (Char.IsLetter(e.KeyChar)) { for (int i = 0; i < (dataGridView1.Rows.Count); i++) { if (dataGridView1.Rows[i].Cells["Name"].Value.ToString().StartsWith(e.KeyChar.ToString(), true, CultureInfo.InvariantCulture)) { dataGridView1.Rows[i].Cells[0].Selected = true; return; // stop looping } } } } I'm sure it's

How to detect pressed keys on the click of AngularJS

社会主义新天地 提交于 2019-12-03 04:35:07
I'm using angularjs on a webapplication that i need to figure out how can i detect is keys like ctrl, shift or alt are pressed when i click some where. for example, with jquery i can do that by accessing the Click function arguments. Is there some out-of-the-box way to obtain that information on angular? Take a look at this beautiful Stuff regarding AngularJS key handling So key code for Ctrl, shift, alt will be Ctrl - 17 Alt - 18 Shift - 16 Working Demo HTML <!DOCTYPE html> <html> <head> <script src="angular.js"></script> <script src="script.js"></script> </head> <body ng-app="mainModule">