keypress

trigger multiple keypress to stimulate keyboard shortcut jquery

和自甴很熟 提交于 2019-12-11 08:09:48
问题 I want to create page zoom - according to keyboard shortcuts by jQuery. Mainly, I want to trigger Ctrl with + and Ctrl with - key pairs, when the user clicks on some element on the page. I have tried this code snippet from Way to trigger multiple keypress and hold events in jQuery question, but it does not work - it does not zoom the page $("#zoom").click(function() { var e = $.Event("keydown"); e.which = 61; // # key code for + e.ctrlKey = true; $(document).trigger(e); }); 回答1: Your event

How do you circumvent repeated keydown messages when you want to use them with javascript where you hold the key down but want it only to play once?

我的梦境 提交于 2019-12-11 08:05:31
问题 I have a piece of code that looks something like below and it works fine. What it does is it launches an oscillator sound when the mouse clicks on a div named synth.It then stops playing the oscillator when the mouse button is released. synth.onmousedown= function () { oscillator = context.createOscillator(), // Creates the oscillator oscillator.type = synthWaveform.value; oscillator.frequency.value = pitchInput.value; oscillator.connect(context.destination); // Connects it to output

Javascript/JQuery How to prevent function from repeatedly executed when holding down key?

两盒软妹~` 提交于 2019-12-11 07:32:51
问题 Let suppose we have the following JQuery Code: $(document).bind('keyup', function(e) { arrows=((e.which)||(e.keyCode)); switch (arrows){ case 37: executeMyfunction(); break; } }); If a user holds down the left arrow key (37) the executeMyfunction() is repeatedly called. How can I prevent this from happening? I thought keyup would trigger only if key is released but its not working (thats why i use keyup, keydown does not work either). 回答1: I believe you have to unbind the event. I think it

Stopping keys from repeating (C#)

ε祈祈猫儿з 提交于 2019-12-11 07:03:00
问题 In this application, I need to be able to stop the response from a key which is held down in order to prevent unnessecary data from entering the output. The problem I'm having is, using the methods in my code below does prevent the keys from repeating, but it also stops them from being responsive enough - as the users are hitting the keys very quickly. I'm not sure if it's my hardware, api restriction or a problem with my code, but the routines I have below do not simply come round fast

How to simulate key presses in C# [closed]

*爱你&永不变心* 提交于 2019-12-11 06:37:44
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . How would you go about sending key commands or keypresses of particular keys in C#, specifically numbers. For instance I would like to simulate typing "512" programatically. Possibly Related: C# SendKeys.Send 回答1

Simulate keystrokes with Quartz events in macOS Sierra

℡╲_俬逩灬. 提交于 2019-12-11 05:29:59
问题 I am simulating keystrokes in macOS, and sending them to the active application. I am doing it along the lines of https://stackoverflow.com/a/27487493/5600424 but in Swift 3. For example, to send an 'a': let eventSource = CGEventSource(stateID: CGEventSourceStateID.hidSystemState) let key: CGKeyCode = 0 // virtual key for 'a' let eventDown = CGEvent(keyboardEventSource: eventSource, virtualKey: key, keyDown: true) let eventUp = CGEvent(keyboardEventSource: eventSource, virtualKey: key,

Python PyQt5 - QEvent Keypress executes double times

人盡茶涼 提交于 2019-12-11 04:38:39
问题 I have this simple code, when ESC key pressed PRINTS, however it seems executing "double" times instead of firing one-time only. Python 3.6.2 x86 + PyQt 5.9 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt from PyQt5 import QtCore, QtGui, QtWidgets class MainWindow(QtWidgets.QWidget): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) qApp.installEventFilter(self) #keyboard control def eventFilter(self,

How can I detect if any key is pressed by the user in C++ (console)?

孤街浪徒 提交于 2019-12-11 04:09:32
问题 I am writing a C++ CLI application how can I detect if any key is pressed by the user. I've seen that in c# but how can it be implement in c++ while(1) { while(/* code to check if any key is pressed*/) { //rest of the code // sleep function } } Hint: like in CLI games to move or to take certain action when a key is pressed or don't do any thing if no input is given. 回答1: On windows at least you could use GetKeyState 回答2: we can use _kbhit() function in c++. _kbhit is equal to 1 if any key is

Robot.keyPress does'nt work for VK_ALT_GRAPH (Invalid key code)

a 夏天 提交于 2019-12-11 02:59:34
问题 I'm working on a remoting app.(mouse - keyboard) I just showing fastly my issue... It's working for 'A' or some basic characters. case "a": robot.keyPress(KeyEvent.VK_A); But I did'nt make '@' character. My way is look like this. case "@": robot.keyPress(KeyEvent.VK_ALT_GRAPH); robot.keyPress(KeyEvent.VK_Q); robot.keyRelease(KeyEvent.VK_ALT_GRAPH); I see the exception when I use VK_ALT_GRAPH; Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid key code at sun

datagridview keypress event for adding new row

限于喜欢 提交于 2019-12-11 02:54:57
问题 i have a datagridview that has 6 column, i want to add a new row every time i press "Tab" button (only) on the last cell of the column, i used the code bellow to prevent adding row everytime i write cell value dataGridView1.AllowUserToAddRows = false; dataGridView1.Rows.Add(); i have already use keypress event on cell[5] (last cell) but it does not work, last cell was set to read only private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e) { if (dataGridView1.CurrentCell