keypress

javascript (jquery) numeric input: keyCode for '3' and '#' are the same

狂风中的少年 提交于 2019-12-30 17:30:56
问题 I need to set up an <input type="text" /> so that it will accept only numeric chars, backspace, delete, enter, tabs and arrows. There's a lot of exemple around there, i started with something similar to this: function isNumericKeyCode (keyCode){ return ( (keyCode >= 48 && keyCode <= 57) //standard keyboard ||(keyCode >= 96 && keyCode <= 105)) //Numpad } $('#myTextBox').keydown(function(e){ var handled = true; var keyCode = e.keyCode; switch(keyCode){ //Enter and arrows case 13: case 37: case

Working with Arrow Keys in a WPF Textbox (C#)

折月煮酒 提交于 2019-12-30 17:23:10
问题 Is there any way to catch the Up/Down arrow keys in a WPF TextBox ( System.Windows.Controls.Textbox ) and allow them to alter the text? I've read about overiding the ProcessCmdKey method for a Windows Forms TextBox ( System.Windows.Forms.TextBox ), and it worked fine, but that TextBox is not nearly as flexible as the WPF one. Is there a similar method to accomplish this without having to use the old Windows Forms TextBox? For my example, I have a TextBox that has a numeric text-mask. I want

Working with Arrow Keys in a WPF Textbox (C#)

强颜欢笑 提交于 2019-12-30 17:23:01
问题 Is there any way to catch the Up/Down arrow keys in a WPF TextBox ( System.Windows.Controls.Textbox ) and allow them to alter the text? I've read about overiding the ProcessCmdKey method for a Windows Forms TextBox ( System.Windows.Forms.TextBox ), and it worked fine, but that TextBox is not nearly as flexible as the WPF one. Is there a similar method to accomplish this without having to use the old Windows Forms TextBox? For my example, I have a TextBox that has a numeric text-mask. I want

Continuous movement with a single key press?

China☆狼群 提交于 2019-12-30 12:11:08
问题 I'm trying to make a program in java that involves making an object move constantly from a single key press. Think Pacman, where you press up once and Pacman continues to go up until you press another key. I want to keep the code simple if possible. My original movement (one keypress = one movement) is like this: public class AL extends KeyAdapter { public void keyPressed(KeyEvent e){ int keyCode = e.getKeyCode(); if(keyCode == e.VK_A){ x -= 5; } if(keyCode == e.VK_D){ x += 5; } if(keyCode ==

C++ how do I terminate my programm using ESC button

被刻印的时光 ゝ 提交于 2019-12-30 11:09:24
问题 Here is my main function i use visual studio 2012 express and the code works fine. My question is how will i terminate this loop when the user Presses the ESC button instead of -1. Although i would prefer a solution that works both in unix and windows, if it is not possible i am most interested in it working for windows. int _tmain(int argc, _TCHAR* argv[]) { list mylist; int value; cout<<"Give the numbers you want to insert to the list, press -1 to stop\n"; do { cin>>value; mylist.insertf

Capture function keys F1..F12 in VB.NET [closed]

佐手、 提交于 2019-12-30 10:07:10
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I cannot capture the function keys F1 .. F12 for my application. I am able to capture regular keys and modifiers such as shift , ctrl , alt , etc.. This

C++ cin keypress event

孤街醉人 提交于 2019-12-30 06:57:11
问题 I believe this is a very simple question, but I can't find a simple answer to it. I have an infinite loop, e.g. while(1) , for(;;) , and I need to break from the loop on a keypress. What is the easiest way to do this? P.S.: I can't use getch , cin.ignore , or cin.get because it stops the loop. 回答1: Well, what you want is asynchronous input. All of the methods provided by cin wait for enter. You will have to use system-specific functions for that, or use a library that will do it for you. What

Jquery: filter input on keypress

混江龙づ霸主 提交于 2019-12-29 06:21:07
问题 I have a text field, which will accept only the following characters: Allowed characters: [a-z 0-9 + # - .] This is the same filter SO does in the 'Tags' field, when you're asking a question. If the user types an invalid character, i want the current text field value to remain unchanged. I tried: $('#post_tags').keypress(function(event){ var char = String.fromCharCode(event.which) var txt = $(this).val() if (! txt.match(/[^A-Za-z0-9+#-\.]/)){ $(this).val(txt.replace(char, '')); } }) Why it

How can I get rid of character repeat delay in C#?

我只是一个虾纸丫 提交于 2019-12-28 19:27:25
问题 http://www.microsoft.com/windowsxp/using/accessibility/characterrepeatrate.mspx - There's an option in Windows for setting repeat delay. It means the delay between first keystroke and the other ones if one keeps pressing the key. I'm creating a sort of game and I need to get rid of this "feature". So far I've managed to find this method: [DllImport("user32.dll")] static extern ushort GetAsyncKeyState(int vKey); public static bool IsKeyPushedDown(Keys keyData) { return 0 != (GetAsyncKeyState(

How can I get rid of character repeat delay in C#?

筅森魡賤 提交于 2019-12-28 19:27:10
问题 http://www.microsoft.com/windowsxp/using/accessibility/characterrepeatrate.mspx - There's an option in Windows for setting repeat delay. It means the delay between first keystroke and the other ones if one keeps pressing the key. I'm creating a sort of game and I need to get rid of this "feature". So far I've managed to find this method: [DllImport("user32.dll")] static extern ushort GetAsyncKeyState(int vKey); public static bool IsKeyPushedDown(Keys keyData) { return 0 != (GetAsyncKeyState(