keydown

Keypress event in C++

天大地大妈咪最大 提交于 2019-12-01 10:49:30
问题 I'm currently using GetAsyncKeyState() to detect Keydown events, but then the events will be repeated while you are holding down the key. What would be an easy way to stop the event from repeating? Example If I hold down the key i on my keyboard for a while, I will get an output like this: iiiiiiiiiiiiiiiiiiiiiiiii Instead of this: i I want to force the user to press the key again to trigger the event. 回答1: Avoid using a keyboard related message like WM_KEYDOWN or WM_CHAR to detect a key,

Capturing of keydown events in a html page with frames

≡放荡痞女 提交于 2019-12-01 09:24:11
问题 I have a jsp page with frames <%@ include file="/includes/taglibs.jsp"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Welcome</title> <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(this).keydown(function(e) { if(e.keyCode==27){ alert("escape pressed"); e.preventDefault(); } }); } ); </script> </head> <frameset rows="42,*"

Detecting keydown and keyup events on Linux C++ [duplicate]

安稳与你 提交于 2019-12-01 08:38:26
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Access Keystrokes in C Monitoring Keyboard keys in Ubuntu I want to detect and time stamp every keydown and keyup event in a program (Yes, I mean keydown and keyup not just keypress) along with what key was pressed. I could do this by using an APi such as GTK, but I want to get as simple and low level as possible in order to avoid overhead from the libraries affecting the times as well as writing less code. I

How to efficiently hold a key in Pygame?

删除回忆录丶 提交于 2019-12-01 08:29:20
[EDIT] I've posted the solution down there. [/EDIT] I've found two related questions: Pygame hold key down causes an infinite loop pygame - on hold button down But I want to be specific. How to? while not done: for e in event.get(): if e.type == KEYDOWN: keys = key.get_pressed() if e.type == QUIT or keys[K_ESCAPE]: done = True if keys[K_DOWN]: print "DOWN" When I press the down arrow, it prints, but it prints just once. If I want to print it another time, I need to press it again. If I use the while keyword instead, while keys[K_DOWN]: print "DOWN" I get an infinite loop for some obscure

How to efficiently hold a key in Pygame?

前提是你 提交于 2019-12-01 06:30:58
问题 [EDIT] I've posted the solution down there. [/EDIT] I've found two related questions: Pygame hold key down causes an infinite loop pygame - on hold button down But I want to be specific. How to? while not done: for e in event.get(): if e.type == KEYDOWN: keys = key.get_pressed() if e.type == QUIT or keys[K_ESCAPE]: done = True if keys[K_DOWN]: print "DOWN" When I press the down arrow, it prints, but it prints just once. If I want to print it another time, I need to press it again. If I use

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

六眼飞鱼酱① 提交于 2019-11-30 21:56:56
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 arrow keys to let the user move the block around, in addition to using a timer to have the shape

How do you detect simultaneous keypresses such as “Ctrl + T” in VB.NET?

喜夏-厌秋 提交于 2019-11-30 12:49:35
I am trying to detect the keys "Control" and "t" being pressed simultaneously in VB.NET. The code I have so far is as follows: Private Sub frmTimingP2P_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyValue = Keys.ControlKey And e.KeyValue = Keys.T Then MessageBox.Show("Ctrl + T") End If End Sub I can detect one key or the other by removing the and statement and the second keyvalue statement, but I don't really get anything when I try this. Is there another method? Thanks First of all, And in your code should be AndAlso since it’s a logical operator.

Handling key events on WebBrowser control

心已入冬 提交于 2019-11-30 09:33:19
I am using the WebBrowser control in a C# application and want to handle all key events while the WebBrowser has the focus, regardless what individual content element (input field, link, etc.) is focused. I tried to simply add an event handler to browser controls KeyDown event, but this does not work. I don't want to explicitly hook a handler to each focusable HtmlElement . How can I receive all key events before they are passed to the browser or its content elements? you have the PreviewKeyDown event just hook it up. private void wb_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { /

Firebug JS warning to jQuery 1.4.2 “The 'charCode' property of a keyup event should not be used. The value is meaningless.” To ignore it?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 09:23:40
问题 Firebug 1.5.4 JavaScript warning : The 'charCode' property of a keyup event should not be used. The value is meaningless. To ignore it? Is there any issue? The warning appears to jQuery 1.4.2 keyup and keydown , not on keypress . I have read that on changing event.keyCode and event.charCode to event.which must fix it, but it does not work for me. Full code example in http://jsfiddle.net/zTevK/2/ and in question My code uses keyup and does not work with keypress . $(document).bind('keyup',

Is it possible to override the keydown repeat delay, in JavaScript?

北城以北 提交于 2019-11-30 06:59:58
问题 The objective is manually set a held key's "repeat rate". For example, when in a text box and pressing and holding the X key, I understand that there is browser-specific ways of repeating the pressed character. In some, it pauses, then continuously triggers the pressed key. In others, it doesn't repeat at all. I want to mitigate this by forcing the pressed key to repeat at a specific interval, regardless of browser. Through research, I've come up with a timer-based attempt, but in Safari, it