keydown

Javascript Toggle on keydown

走远了吗. 提交于 2019-12-20 05:23:11
问题 I'm pretty new when it comes to getting my head around JS functions. Everything I've used before, I've tended to use as-is, but I've been trying to combine and modify a function to get a Div to toggle (height & opacity) on a specific keypress. I have the first part (can get the div to show on a 'ctrl + o' combo), but can't combine it with an if statement to show or hide, based on current display status. Current working 'show only' JS: $(document).keydown(function (e) { if (e.keyCode == 79 &&

How to prevent controls from capturing KeyDown events while a modal form is open?

馋奶兔 提交于 2019-12-20 04:07:11
问题 I have a form with CancelButton and AcceptButton (named btnCancel and btnOK). And I have some ComboBoxes as input fields. ComboBoxes prevent my AcceptButton and CancelButton to receive Escape and Enter keys, so I added this code to KeyDown event for all fields: if (e.KeyData == Keys.Escape) { ComboBox field = (ComboBox)sender; if ((field.DropDownStyle == ComboBoxStyle.Simple) || (!field.DroppedDown)) { e.SuppressKeyPress = true; btnCancel.PerformClick(); } } else if (e.KeyData == Keys.Enter)

multiple simultaneous key press c#

不打扰是莪最后的温柔 提交于 2019-12-19 20:42:34
问题 I am programming a game in microsoft visual studio c# and I have to catch lot's of keys simultaneously. I can't detect Q,W,E,R,T,Y at the same time but I can detect Q,W,E,R,T,A. I tried to use KeyDown and [DllImport("user32.dll")] but both of them has the same result. What is the difference between Y and A keys and how can I solve this problem? int code1 = GetVirtualKeyCode(Keys.Q); int code2 = GetVirtualKeyCode(Keys.W); int code3 = GetVirtualKeyCode(Keys.E); int code4 = GetVirtualKeyCode

multiple simultaneous key press c#

浪尽此生 提交于 2019-12-19 20:41:11
问题 I am programming a game in microsoft visual studio c# and I have to catch lot's of keys simultaneously. I can't detect Q,W,E,R,T,Y at the same time but I can detect Q,W,E,R,T,A. I tried to use KeyDown and [DllImport("user32.dll")] but both of them has the same result. What is the difference between Y and A keys and how can I solve this problem? int code1 = GetVirtualKeyCode(Keys.Q); int code2 = GetVirtualKeyCode(Keys.W); int code3 = GetVirtualKeyCode(Keys.E); int code4 = GetVirtualKeyCode

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

穿精又带淫゛_ 提交于 2019-12-19 03:42:12
问题 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(), canMoveLeft(), canMoveRight() boolean functions that verify it's ok to move). This is all working beautifully. I want to use the down, right, and left

keydown + keyup events for specific keys

让人想犯罪 __ 提交于 2019-12-18 11:32:00
问题 I'm trying to make the background color change when certain keys are held down. For example, when the 'r' key is being held down, the background should be red. When the 'r' key is not being pressed anymore, the background should default to white. $(document).ready(function () { $('body').keydown(function(e){ if(e.keyCode == 114){ $(this).css({'background':'red'}); } if(e.keyCode == 121){ $(this).css({'background':'yellow'}); } }); $('body').keypress(function(e){ if(e.keyCode == 114){ $(this)

Reading keydown regardless of active application in vb.net

◇◆丶佛笑我妖孽 提交于 2019-12-18 07:21:09
问题 I asked a question earlier about keyhooks in vb.net. My current issue is such: I have created a program which should perform a certain action whenever a certain group of keys is pressed at the same time. The program must be able to run in the background, or in the system tray or something. Essentially, this should work like the KeyDown event on a form, except the form in this case is everything. I'm not certain if there is a way to do this directly from within the .net API, but if there is I

Javascript sending key codes to a <textarea> element

主宰稳场 提交于 2019-12-18 05:22:29
问题 I can't figure out how to trigger a keydown event on a textarea element, e.g. imagine i have two textarea elements and when i type something in the first one, I want the second box to show the typing as well, but for a certain reason I have to do it via events. This is what I tried and it doesn't work: <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <textarea id='first'></textarea> <textarea id='second'><

jQuery: How to catch keydown + mouse click event?

瘦欲@ 提交于 2019-12-18 03:32:18
问题 I have a div element. I need to catch a mouse click on this div while alt-key (keyCode = 17) is pressed. Here is what i've got to catch key press: // Html <div id="targetDiv">I want to put a ding in the universe.</div> // Java-script $(document).ready(function(){ $(window).bind('keydown', function(event){ if ( 17 == event.keyCode ) { // How to catch mouse click on $('#targetDiv') ? } }); }); How to catch mouse click on div while alt-key is pressed? 回答1: You can check the .altKey property, for

keydown (repetition) breaks when keyup event (for ANOTHER key) is fired

二次信任 提交于 2019-12-17 20:31:27
问题 This is a bit of a weird one so I figure I'm either missing something obvious or this is a flaw with how these events are implemented in browsers. Let me first summarize an example scenario this issue comes up with before providing an isolated case-example; The arrow keys are used to move the player (as a handleKeyDown function is fired anytime a key is hit anywhere on the page). Likewise, anytime a key is released another function is fired (handleKeyUp). As you (the player) hold the left key