keydown

Passing Parameters to KeyDown

血红的双手。 提交于 2019-12-11 06:12:23
问题 How can you pass parameters into the keydown method from jquery because whenever I use a variable defined elsewhere it returns undefined. I assume its because the #target is window and therefore its not in the scope but even then I have trouble getting it to compare the key.which() with an outside parameter and then assigning it to another property. Example: var a = 38; var b = 0; $(document).keydown(function(e){ var key = e.which; if (a==key) b=key; }); console.log(a+""+b); Whenever I try to

How can I detect if any key is pressed by the user in C++ (console)?

孤街浪徒 提交于 2019-12-11 04:09:32
问题 I am writing a C++ CLI application how can I detect if any key is pressed by the user. I've seen that in c# but how can it be implement in c++ while(1) { while(/* code to check if any key is pressed*/) { //rest of the code // sleep function } } Hint: like in CLI games to move or to take certain action when a key is pressed or don't do any thing if no input is given. 回答1: On windows at least you could use GetKeyState 回答2: we can use _kbhit() function in c++. _kbhit is equal to 1 if any key is

Javascript movement on key hold

橙三吉。 提交于 2019-12-11 02:01:08
问题 I need help with a movement function for a canvas game. Below is what I have, and what happens is the player only changes direction when a left/right key is pressed. It would be ideal for the player to face the corresponding direction from holding down either the left or right arrow keys, which currently doesn't occur. I have no idea how to do this, any ideas? I now have movement direction working on key hold down, updated below, but when the page first loads, the player is not displayed on

Problem with OnKeyDown in Delphi

谁说胖子不能爱 提交于 2019-12-11 01:47:39
问题 I am working with Delphi. I want to track on which key is pressed. I am using KeyDown event of TForm. It is working fine but the problem is that, if I press and lower case letter, though it gives me upper case of that letter. How can I recognize the key pressed is lower case or upper case? 回答1: If you want to track alphanumerical keys, then you should use KeyPress . Try this: procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin ShowMessage(Key); end; The problem with KeyDown

Trouble creating KeyDown event in Panel

人盡茶涼 提交于 2019-12-10 23:24:27
问题 I am currently working on winform that has a panel on it. I need to be able to use the up, down, left and right arrows on the panel and get something to happen. I tried adding the event with this line of code: (MainPanel as Control).KeyDown += new KeyEventHandler(panelKeyPressEventHandler); With this KeyDown code: public void panelKeyPressEventHandler(object sender, System.Windows.Forms.KeyEventArgs e) { MessageBox.Show("Here I am!"); switch (e.KeyCode) { case Keys.L: { break; } case Keys.R:

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

一笑奈何 提交于 2019-12-10 18:35:11
问题 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 KeyListener.keyDown */ public boolean keyDown(int keycode, int time) { boolean retval = false; switch (Keypad.key(keycode)) { /* DELETE - Delete the timer */ case Keypad

How to disable repetitive keydown in JavaScript [duplicate]

夙愿已清 提交于 2019-12-10 03:22:44
问题 This question already has answers here : Prevent JavaScript keydown event from being handled multiple times while held down (7 answers) Closed 3 years ago . I have a same problem like this guy How to disable repetitive keydown in jQuery , it's just that I'm not using jQuery so I'm having hard time translating it to "pure" JavaScript, anyways I have set switch -case of some keys and when I press and hold right arrow key my div is flying. Also if it's not a problem can you tell me what would be

Is it possible to block the Windows Key from a web browser?

做~自己de王妃 提交于 2019-12-09 03:54:18
问题 I have a fairly sophisticated Single Page Application, with a nice little menu system (similar to Windows 8 start menu). I'd like for my users to hit the Windows key to open this menu when within my application. I have this successfully functioning, however it also brings up the Microsoft Windows start menu. Is there a way (from a web browser) I can "block" the Microsoft Windows Start Menu from appearing when I hit the Windows Key within my web app? I'm using latest jQuery, knockoutJS, and

KeyDown recognizes the left and right directional arrow keys, but not up and down

拟墨画扇 提交于 2019-12-08 21:53:29
问题 With the code below, the Left and Right arrow keys function as expected, but the up and down arrows are not recognized (stepping through it, the first two conditions are met where appropriate, but the second two never are): private void textBox1_KeyDown(object sender, KeyEventArgs e) { TextBox tb = (TextBox)sender; if (e.KeyCode.Equals(Keys.Left)) { SetFocusOneColumnBack(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Right)) { SetFocusOneColumnForward(tb.Name); e.Handled =

wpf : how to handle KeyDown Event for Datagrid?

两盒软妹~` 提交于 2019-12-08 21:48:06
问题 I have a problem with datagrid control in wpf . when I press enter I want to load selected items in a set of controls, but it seems that datagrid.KeyDown is already handled and it goes to the next item. I tried using keyup but this event fires when the datagrid keydown had been fired and datagrid goes to the next item. any idea to handle keydown completely ? 回答1: Use the PreviewKeyDown event instead of KeyDown 回答2: Maybe KeyDown is handled by a ClassHandler. Instance listeners come after