keypress

Restricting keyboard input with keypress jQuery

旧街凉风 提交于 2019-12-20 05:25:09
问题 I have a keypress function I created with a game to take user input in a form with the enter button (and to have a series of functions I defined first go in sequence on the Enter key being pressed). $(".form-control").keypress(function(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == 13) { var space = $(this).val().toLowerCase(); if (!(wrongGuesses.indexOf(space) > -1 || rightGuesses.indexOf(space) > -1)) { play(space); $(this).val(''); endGame(); return

Capture key events from a Windows Service in C#

杀马特。学长 韩版系。学妹 提交于 2019-12-20 03:40:16
问题 I have to write an application in C# that listens to any keys being pressed. In actuality I have a bar code scanner sending the "key pressed" event, and I need to listen it... what it does from there is beyond the scope of my question. My security requirements are that there is not allowed to be any sign-on to the machine in any way shape or form AND this must run as a windows service . The user will start the machine and walk away (i.e., no desktop session). I'm assuming I'm going to have to

Pygame waiting the user to keypress a key

…衆ロ難τιáo~ 提交于 2019-12-20 03:16:38
问题 I am searching a method, where the program stops and waiting for a spesific key to be pressed by the user. May I can implement this one with a while loop? I need the best algorithm, if there exist a build-in function of waiting, to avoid the loop. I found several information on the official website of pygame, but nothing help. Here is a testing algorithms but won't work: key = "f" while key != "K_f": key = pygame.key.get_pressed() if key[Keys.K_f]: do something... 回答1: You could do it with a

Polymer keypress event handler not being called

我的未来我决定 提交于 2019-12-20 02:19:06
问题 Can't figure out why in the following polymer I am unable to get the keypressHandler function to be called. What am I doing wrong? (I tried putting the on-keypress attribute on the span element itself, but still no cigar.) The rest of the functionality works as expected. <link rel="import" href="../bower_components/polymer/polymer.html"> <polymer-element name="psq-posscell" attributes="isposs nVal" on-tap="{{toggle}}" on-keypress="{{keypressHandler}}" > <template> <link rel="stylesheet" href=

Keypress To Simulate A Button Click in C#

别等时光非礼了梦想. 提交于 2019-12-19 10:11:37
问题 Ok, so I'm in the process of making a Tic-Tac-Toe game to help me learn C#. I'm attempting to add a bit of functionality to it, so I want people to be able to use the NumPad on a computer to simulate clicking the buttons. Here is what I have but when I use the NumPad the buttons don't click. Can any of you see a reason as to why? //=============================== // start NumPad Simulate Clicks // NumPad MyButtons // 7 8 9 1 2 3 // 4 5 6 4 5 6 // 1 2 3 7 8 9 //===============================

How can I make my Windows Forms application 'listen' for global key presses?

[亡魂溺海] 提交于 2019-12-19 09:07:52
问题 I'm making a little application for taking notes. So when I type 'note' anywhere on my computer, my window will pop up and show me a textbox for me to type something in and save it to XML. I'm stumped on how to get the program to 'listen' to my keypresses. I'll have the app running on the system tray if that's any help. :) 回答1: Take a look at http://www.codeproject.com/KB/cs/globalhook.aspx Besides this question has been asked around in SO already. Take a look at here: Global Keyboard Hooks

Invoking KeyPress Event Without Actually Pressing Key

倾然丶 夕夏残阳落幕 提交于 2019-12-19 02:54:16
问题 Just wondering. Is it possible to invoke a key press event in JavaScript without ACTUALLY pressing the key ? For example lets say, I have a button on my webpage and when that button is clicked I want to invoke a event as if a particular key has been pressed. I know it weird but can this be done in JavaScript. 回答1: Yes, this can be done using initKeyEvent. It's a little verbose to use, though. If that bothers you, use jQuery, as shown in @WojtekT's answer. Otherwise, in vanilla javascript,

Why pressing of “Tab” key emits only QEvent::ShortcutOverride event?

我的未来我决定 提交于 2019-12-18 13:23:14
问题 Background Hi guys. I've made a custom widget with QLineEdit and several QPushButtons to use it with custom item delegate: class LineEditor : public QWidget { public: explicit LineEditor(QWidget *parent = 0) : QWidget(parent) { setLayout(new QHBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); QLineEdit *edit = new QLineEdit(this); layout()->addWidget(edit); layout()->addWidget(new QPushButton(this)); layout()->addWidget(new QPushButton(this)); setFocusProxy(edit);

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)

How to use Enter key as Tab key in DataGridView

大城市里の小女人 提交于 2019-12-18 09:14:47
问题 I have a DataGridView with 5 columns. If press Enter key in the first column, focus moves to next row. I want to move the focus to the next column when I press Enter key. private void dgvComp_CellEnter(object sender, DataGridViewCellEventArgs e) { if (dgvComp.CurrentRow.Cells[e.ColumnIndex].ReadOnly) { SendKeys.Send("{tab}"); } } In the above code I have columns 2,3 and 4 as read only columns. If I press Tab, focus should directly go to 5th column. How can I do that? 回答1: would you pls try