keyboard-events

How to get a combination of keys in c#

夙愿已清 提交于 2019-12-17 06:50:32
问题 How can I capture Ctrl + Alt + K + P keys on a C# form? thanks 回答1: It is a chord, you cannot detect it without memorizing having seen the first keystroke of the chord. This works: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private bool prefixSeen; protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (prefixSeen) { if (keyData == (Keys.Alt | Keys.Control | Keys.P)) { MessageBox.Show("Got it!"); } prefixSeen = false; return true; } if

Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser

早过忘川 提交于 2019-12-17 03:02:40
问题 I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3. Any suggestions to a full cross-browser solution? Something like a well-tested jQuery library or maybe just vanilla jQuery/JavaScript? 回答1: The best source I have for this kind of question is this page: http://www.quirksmode.org/js/keys.html What they

How can I programmatically generate keypress events in C#?

久未见 提交于 2019-12-16 20:52:41
问题 How can I programmatically create an event that would simulate a key being pressed on the keyboard? 回答1: The question is tagged WPF but the answers so far are specific WinForms and Win32. To do this in WPF, simply construct a KeyEventArgs and call RaiseEvent on the target. For example, to send an Insert key KeyDown event to the currently focused element: var key = Key.Insert; // Key to send var target = Keyboard.FocusedElement; // Target element var routedEvent = Keyboard.KeyDownEvent; //

How can I programmatically generate keypress events in C#?

时光怂恿深爱的人放手 提交于 2019-12-16 20:51:21
问题 How can I programmatically create an event that would simulate a key being pressed on the keyboard? 回答1: The question is tagged WPF but the answers so far are specific WinForms and Win32. To do this in WPF, simply construct a KeyEventArgs and call RaiseEvent on the target. For example, to send an Insert key KeyDown event to the currently focused element: var key = Key.Insert; // Key to send var target = Keyboard.FocusedElement; // Target element var routedEvent = Keyboard.KeyDownEvent; //

PyGame not receiving events when 3+ keys are pressed at the same time

家住魔仙堡 提交于 2019-12-14 04:18:29
问题 I am developing a simple game in PyGame... A rocket ship flying around and shooting stuff. Question: Why does pygame stop emitting keyboard events when too may keys are pressed at once? About the Key Handling: The program has a number of variables like KEYSTATE_FIRE, KEYSTATE_TURNLEFT , etc... When a KEYDOWN event is handled, it sets the corresponding KEYSTATE_* variable to True. When a KEYUP event is handled, it sets the same variable to False. The problem: If UP-ARROW and LEFT-ARROW are

Detect single key press in JavaFX

倾然丶 夕夏残阳落幕 提交于 2019-12-14 03:52:06
问题 I have a problem of detecting a single key press in JavaFX. I have to detect arrow keys but each time I press any of those keys part of my code is being called multiple times. I realize that it is because AnimationTimer() is a loop thus this is the reason but I have no idea how to detect single key tap. Anyways, here is the code: import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene

key_down delay action script 3

血红的双手。 提交于 2019-12-14 02:53:22
问题 When you hold down the key After first pressing the next press is delaying but I don`t know why. public function KeyboardControl(event:KeyboardEvent):void { keySpeed=5 if(event.keyCode==Keyboard.RIGHT||event.keyCode==Keyboard.D) { if(_Vx<0) { _Vx=0; } _Vx += (keySpeed/mass); } if(event.keyCode==Keyboard.LEFT||event.keyCode==Keyboard.A) { if(_Vx>0) { _Vx=0; } _Vx -= (keySpeed/mass); } } 回答1: For more responsive behaviour, structure it like this: private var _Vx:Number = 0; private var keySpeed

How to capture keyboard event without Enter key in java/scala?

可紊 提交于 2019-12-14 02:34:51
问题 I'm writing a game based on terminal and I want capture keyboard event, such as w/a/s/d as direction of Up/Left/Below/Right, rather then readLine a input stream with a Enter key. Besides, I have read swing package, it has some KeyListener interface but it seems must bind with swing UI. Does there have pure keyboard event without other technology binding in java world? 来源: https://stackoverflow.com/questions/41938109/how-to-capture-keyboard-event-without-enter-key-in-java-scala

View keeps moving down in iPhoneX on keyboard dimissal

情到浓时终转凉″ 提交于 2019-12-13 17:23:55
问题 I'm carrying out tests on different devices and have noticed a problem when I come to test on an iPhone X. Basically, on my view, I have an image, a text-field and a button; all within a stack view that is centred horizontally and vertically. When I tap the text-field and the keyboard presents itself, I move the view upwards so as not to block any content with the keyboard - and vice-versa when the keyboard returns. Here is my code: @objc func keyboardWillShow(notification: NSNotification) {

Why would my app not be able to “attach” an action?

社会主义新天地 提交于 2019-12-13 17:06:58
问题 I've changed my app class type from NSObject to NSApplication and now I get the following message when testing my app: Could not connect the action buttonClicked: to target of class NSApplication What does this mean and how can I fix it? 回答1: NSApplication does not respond to the buttonClicked: method and, therefore, there is no way for the target/action connection to be successfully made. 来源: https://stackoverflow.com/questions/3886029/why-would-my-app-not-be-able-to-attach-an-action