keyboard-events

How to detect key press event and key hold down event without using pygame

こ雲淡風輕ζ 提交于 2019-12-21 06:19:28
问题 I am currently looking for a library that is able to detect/monitor the keyboard. My intention is to detect when a key is being held down and while it occurs something should happen. Most SO posts suggest to use pygame, but i find it a bit too much, to involve a library such as that for this simple task. i've also tried with pynput , which resulted only detecting one press rather than a stream of presses. any suggestions on how i can make this while loop detect a key is being pressed / held

iPad, JavaScript character codes, and shiftKey

牧云@^-^@ 提交于 2019-12-21 04:43:18
问题 Say I have a web application that calls the following jQuery every time a user presses a key in a textarea with an ID of "txt": $('#txt').keydown(function(e) { console.log(e.which); // shows the keyCode console.log(e.shiftKey); } On a desktop browser, for characters like ( and 9 , I can distinguish between the two by checking to see if the shift key is held down (with e.shiftKey). However, in Safari for iPad, there is no shift key required to type those characters. So, for example, pressing

How to capture enter key being pressed on pages containing multiple forms?

痴心易碎 提交于 2019-12-20 09:01:15
问题 I have inherited a web application where the usual ability to press return in any of the input fields has been disabled for the very good reason that the page contains multiple forms, and the application would not be able to determine (or, so I am told) which form to action. The application has been designed so there are no submit buttons (as in input type="submit") and, instead, the designers have gone for onclick handling. Here are two buttons that are defined on one of the pages, included

Selecting div in custom dropdown using Keyboard (Up, down and enter keys)

守給你的承諾、 提交于 2019-12-20 06:56:07
问题 I have simulated a dropdown look alike using div. I have also implemented search functionality for the values in dropdown div. I am trying to select the options in div dropdown using keys. When i search for a particular query and try to select the options presented, its not working. Can anyone please suggest solution. Code present here ---> http://jsbin.com/ujimih/2/edit Updated code present here ---> http://jsbin.com/ujimih/10/edit 来源: https://stackoverflow.com/questions/16573869/selecting

In Android Custom Keyboard, how to change Alphabets Keyboard to Symbols Keyboard?

天涯浪子 提交于 2019-12-20 03:50:11
问题 While Navigate User from Alphabets Keyboard to Symbols Keyboard, Layout Alignment gets spoiled. By Default, Layout takes 5dp padding & User can't see the Last Column Keys. Note: Images shown in below. I handled Key Actions to Navigate User from Alphabets Keyboard to Symbol Keyboard in the onKey Method override fun onKey(primaryCode: Int, keyCodes: IntArray?) { when (primaryCode) { KEYCODE_ALPHABETS -> { keyboardView?.keyboard = Keyboard(this, R.xml.keyboard) } KEYCODE_SYMBOLS_1 -> {

Correctly getting key being pressed for chat in XNA

北慕城南 提交于 2019-12-20 03:48:08
问题 So, I'm going to cut straight to it, I'm trying to make a chat system in an XNA game I'm making. I can easily figure out what keys are being pressed BUT I have no way of knowing what is actually being typed. To me, it looks like they are saying: OemShifthello billOemPeriod OemShifthow are youOemQuestion which should look like Hello bill. How are you? (or something along those lines). Whats the best way to handle all of this? 回答1: For the PC there's nothing built in to the XNA framework making

JavaFX: How to move 2 Rectangles at the same time?

只谈情不闲聊 提交于 2019-12-20 03:27:09
问题 I have 2 rectangles representing the paddles for my Pong game. I use W/S for one rectangle and UP/DOWN for the second rectangle. When I press W to move one rectangle and then press UP to move the second rectangle, the first rectangle will stop moving and then the second rectangle will move. How do I make it so both rectangles can move simultaneously? GraphicsContext gc; Rectangle player11; Rectangle player22; Circle ball; private int y1; private int p1y = 381; private int y2; private int p2y

Catching Qt modifier key releases

狂风中的少年 提交于 2019-12-20 01:17:09
问题 I'm a newcomer to Qt, but I'm trying to implement what basically amounts to a video-game-esque input loop in a Qt application (crazy, I know, but see if you can help). I need accurate, one-to-one event handling for key presses and key releases, for all keys, including modifiers, no matter how weirdly you chord-up the keyboard. Of course, your main access to key events is through QKeyEvent . But let's say the following happens: user presses and holds Ctrl user presses and holds Up user

Send Windows key keypress into application [duplicate]

血红的双手。 提交于 2019-12-20 01:01:25
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to detect the currently pressed key? (EDIT: For what it's worth, this is not a duplicate... not sure why it was voted as such) I have a small timer application that we use in the office to track the hours spent on a project. There is a start and stop button, and a project and task fields. When we go on break and to lunch and other things, we stop the timer for that project, then restart it. This is a

GetKeyboardLayout() doesn't work properly in some cases

走远了吗. 提交于 2019-12-19 20:01:22
问题 I'm writting console app that should indicate keyboard layout. I'm using GetForegroundWindow() function to get current active window, function GetWindowThreadProcessId() to get thread id, and finally, with function GetKeyboardLayout() I get keyboard layout. Everyting works fine with any application I try except some cases: When I switch window to cmd.exe or any other console app it shows default layout, changing layout have no effect In games is the same situation All threads of the same