keyboard-events

How to simulate typing in input field using jQuery?

假如想象 提交于 2019-11-27 00:21:03
问题 What I want is to simulate typing in <input> field using javascript. I have the following code: var press = jQuery.Event("keydown"); press.ctrlKey = false; press.which = 65; $("#test").trigger(press); But when I load the page, the #test input field has no typed characters, the keycode of '65' represents 'A', but there is no 'A' input. Basically what I want is to automatically typing in the website using Greasemonkey. Please give me some ideas or some library with which I can use to do this.

How to simulate a Ctrl A + Ctrl C using keybd_event

时光总嘲笑我的痴心妄想 提交于 2019-11-26 23:23:58
问题 How to simulate a Ctrl - A + Ctrl - C using keybd_event ? Because I am simulating a ctrl a + ctrl c on a webbrowser form to copy the entire contents on clipboard. i used the SendKeys.SendWait but it is not copying the entire contents! 回答1: This should work [DllImport("user32.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); public const int KEYEVENTF_KEYDOWN = 0x0000; // New definition public const int KEYEVENTF_EXTENDEDKEY =

c# Sending keyboard commands to another window / process

感情迁移 提交于 2019-11-26 22:52:15
问题 I am trying to write a program that will take a line of data and pass it into another window / process. This is the code I have so far, but I have not been able to work out how I would send the keyboard command to the OUTLOOK process. I would like to be able to use the Tab command / key and the Enter command / key. This is what I have tried so far using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading; using System.Runtime

How to stop repeated keyPressed() / keyReleased() events in Swing

假装没事ソ 提交于 2019-11-26 22:51:54
So the problem that I am having appears to be a bug that occurs only on Linux. I'm trying to have my swing app record when a key is pressed down, then to detect when that key is released. Now that shouldn't be in issue because KeyListener is supposed to handle this for me. The problem is that when I hold the key down I get lots of repeated keyPressed()/keyReleased() events instead of just the single keypressed(). Does anyone have a solution or workaround for knowing when a key is really released on linux? Thank you. So the problem that I am having appears to be a bug that occurs only on Linux

Javascript, key press value is always one character behind the latest?

旧城冷巷雨未停 提交于 2019-11-26 22:01:04
问题 If I type 'St', by the time I press the t, if I output the input of textfield.value in the onkeypress / onkeydown functions, I only get 'S'. Why is this? How do I get rid of this lag? 回答1: use the keyup event instead of keypress . keydown will show the before-keystroke value, as will keypress (apparently). 回答2: Within the keypress event, it's still possible to prevent the typed character from registering, so the input's value canot be updated until after the keypress event. You can use the

How to grab keyboard events on an element which doesn't accept focus?

我只是一个虾纸丫 提交于 2019-11-26 20:10:25
问题 I know that for handling keyboard events in an input field you can use: $('input').keyup(function(e){ var code = e.keyCode // and 13 is the keyCode for Enter }); But, now, I have some div and li elements, and I don't have a form element, and none of my elements are considered to be form elements and none of them accept focus or tab and stuff like that. But now I need to handle the keyup (or keydown , or keypress , doesn't matter) event in a div element. I tried: $('div#modal').keyup(function

How to detect if the pressed key will produce a character inside an <input> text-box?

一笑奈何 提交于 2019-11-26 19:49:29
问题 I have a regular text-box: <input type="text"> I use jQuery to handle key-related events: $("input:text").keydown(function() { // keydown code }).keypress(function() { // keypress code }).keyup(function() { // keyup code }); The user focuses on a text-box and presses various keys on his keyboard (the usual ones: letters, numbers, SHIFT, BACKSPACE, SPACE, ...). I need to detect when the user presses a key that is going to increase the length of the text-box value. For example, the "A" key will

How do you check for keyboard events with kivy?

大城市里の小女人 提交于 2019-11-26 17:47:54
问题 So, awhile ago, I started teaching myself kivy. I started with the main kivy website and went through its pong making tutorial and upon finishing that I decided to try and give it key input. I just can't seem to find any kind of guide to key input with kivy! Anyone know some kind of tutorial or can provide some easy to understand code? I did look at the Keyboard Listener in the examples folder of kivy, but I'm not quite sure how to use that if I'm supposed to. Thanks for any assistance. 回答1:

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

ⅰ亾dé卋堺 提交于 2019-11-26 15:19:05
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? The best source I have for this kind of question is this page: http://www.quirksmode.org/js/keys.html What they say is that the key codes are odd on Safari, and consistent everywhere else (except that there's no keypress

C++ console keyboard events

爷,独闯天下 提交于 2019-11-26 11:37:39
问题 Is there any way to get key events in a Windows console? I need a way to get keydown and keyup events quickly without a GUI. I\'ve tried using getch(), but it doesn\'t get keyups and waits until a key has been pressed to return. 回答1: You can use GetKeyState or GetAsyncKeyState , but that won't give you keydown/keyup events. It will only tell you what keys are currently down. So if you really need to get the keydown/keyup events, you could install a hook. A Console window has a window handle