keydown

Concat KeyDown event (Keys) to one C# (wpf) string

怎甘沉沦 提交于 2019-12-04 06:48:25
I have a magnetic card reader that uses the keyboard input to send data. I am using a KeyDown event where I get this object (C# WPF): KeyEventArgs e I want to take the keys that I get and make them one string. I tried to concat e.Key.ToString() , but that doesn't work. My input has lots of numbers and signs (such as ; ? = etc.), and the e.Key.ToString() thing doesn't work (it gives me D3 for a number, and SHIFT or CTRL + another key for the signs). I just want the string, so when I use for example Console.WriteLine I will get something like ;51895401051=000001341? and not

e.preventDefault(); behaviour not working in Firefox?

本秂侑毒 提交于 2019-12-04 05:40:22
问题 I have this basic function for handling the key event, everything works great. However, in Firefox 9.0.1 it seems I can't prevent the default event which is showing of bookmarks. Is there any solution to prevent the default behaviour in FF? $(document).keydown(function(evt) { if (evt.which == 66 && evt.ctrlKey) { if (evt.preventDefault) { evt.preventDefault(); } else { evt.returnValue = false; } alert("Ctrl+B pressed"); return false; } }); 回答1: Seems like some sort of bug regarding alert .

JavaScript: input validation in the keydown event

佐手、 提交于 2019-12-04 05:33:24
I'm attempting to do info validation against user text input in the process of keydown event. The reason that I am trying to validate in the keydown event is because I do not want to display the characters those that are considered to be illegal in the input box at the beginning. The validation I am writing is like this, function validateUserInput(){ var code = this.event.keyCode; if ((code<48||code>57) // numerical &&code!==46 //delete &&code!==8 //back space &&code!==37 // <- arrow &&code!==39) // -> arrow { this.event.preventDefault(); } } I can keep going like this, however I am seeing

C# Stopwatch on-the-fly update

北战南征 提交于 2019-12-04 05:07:11
问题 (My first question here!) Hi, I am kind of beginner in c#. I tried to build a simple timer (in Windows.Forms). I made a label which indicates the time, and used the StopWatch class (from system.diagnostics). The trigger event for starting / stopping the stopwatch is the spacebar KeyDown event. After the second tap the stopwatch stops and Label.text is assigned to the Stopwatch.Elapsed value. I want to continuously update the label, but I don't know how. If I make while(StopWatchName.IsRunning

Javascript: Keydown Event: “Up” arrow key preventing further arrow-key Keydown events? (answered: keyboard ghosting)

流过昼夜 提交于 2019-12-04 03:10:00
问题 I've found a lot of related questions (here and elsewhere), but haven't found this one specifically. I'm trying to listen for keydown events for the arrow keys (37-40), however when using the arrow keys in a certain order, subsequent arrow do not generate "keydown" events. Example: http://blog.pothoven.net/2008/05/keydown-vs-keypress-in-javascript.html At that page, click in the "type here ->" box. Press and hold right arrow key: table updates to keycode 39 While continuing to hold right

Get keyDown event for an NSTextField

我是研究僧i 提交于 2019-12-04 02:34:43
In xcode last version, I am trying to get the keyDown event of an NSTextField. However, despite following multiple tutorials on the internet (delegates, controllers...), I still can't receive it. Any easy hint for me ? Thanks ! Scott Jenkins I got sick of all the non answers to do it some other way people so I put my nose down and figured out a way to make this work. This isn't using keydown event directly but it is using the keydown in the block. And the behavior is exactly what I wanted. Subclass the text field .h @interface LQRestrictedInputTextField : NSTextField .m In the become first

How to disable/remove only first space on input field?

这一生的挚爱 提交于 2019-12-03 20:46:57
Good morning everybody! I have a case, when I should prevent users to entering space as a first character on input field. I have a demo here: http://jsbin.com/foyetolo/2/edit It works only when you hit spacebar for first time. When you start typing other characters and select whole text in input (ctrl+a) and then hit the space bar it adds the space in the beginning of input field. So, how to check if on keypress/keydown if the first character will be a space, return false and not allow it to type the space as a first character? You can do this by checking if key is space and selection start is

jQuery .keypress & .keydown .which

混江龙づ霸主 提交于 2019-12-03 18:39:50
问题 Ok so what is the difference in .keypress and .keydown/.keyup? At present I am using .keydown which returns a .which value of 38 for my key, now if i change it to .keypress it returns a value of 109 for that same key. What is the difference and why are the values different for the same key? 回答1: If you press a button it fires a keydown and releasing it fires a keyup . The keypress usually comes between those two. keydown and keyup talk about which key has been changed. keypress tells which

How to set an evenHandler in WPF to all windows (entire application)?

最后都变了- 提交于 2019-12-03 17:08:29
How can I set an event handler (such as keydown ) to entire solution, not a single window? Register a global event handler in your application class (App.cs), like this: public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); EventManager.RegisterClassHandler(typeof(Window), Window.KeyDownEvent, new RoutedEventHandler(Window_KeyDown)); } void Window_KeyDown(object sender, RoutedEventArgs e) { // your code here } } This will handle the KeyDown event for any Window in your app. You can cast e to KeyEventArgs to get to the information

Keys pressed at the same time

点点圈 提交于 2019-12-03 16:35:49
Can I know the number of keys pressed at the same time in Javascript? If so, how can I have an array of their keyCode ? You can listen for keydown and keyup events. var keys = { length: 0 }; document.onkeydown = function(e){ if(!keys[e.keyCode]) { keys[e.keyCode] = true; keys.length++; } } document.onkeyup = function(e){ if(keys[e.keyCode]) { keys[e.keyCode] = false; keys.length--; } } Then all the keys that are true are the ones that are pressed currently. Fiddle demo thanks to @Esailija: http://jsfiddle.net/maniator/Gc54D/ This should do the trick. It is similar to Neal's, but should fix a