keyboard-events

Ruby Keyboard event handling

倾然丶 夕夏残阳落幕 提交于 2019-11-29 16:46:43
Hello im using curses to develop a small console application. I have a main loop section wich waits for user input, it uses the getstr function, of course this waits for the user to press enter. I would like to capture the up and down and tab keypresses. I suppose this can't be done with getstr. Anyone have any idea how to do this? EDIT: i've tried using STDIN.getc wich blocks the application from running, and getch doesnt catch the arrow keys EDIT #2 : im trying this code on windows. It seems that Curses.getch works for linux, but on windows i get no key sent for the up arrow. You need to set

Global keyboard hook with WH_KEYBOARD_LL and keybd_event (windows)

穿精又带淫゛_ 提交于 2019-11-29 15:10:37
问题 I am trying to write a simple global keyboard hook program to redirect some keys. For example, when the program is executed, I press 'a' on the keyboard, the program can disable it and simulate a 'b' click. I do not need a graphic ui, just a console is enough (keep it running) My plan is to use global hook to catch the key input, and then use keybd_event to simulate the keyboard. But I have some problems. The first problem is that the program can correctly block 'A' but if I hit 'A' on the

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

廉价感情. 提交于 2019-11-29 13:33:45
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? use the keyup event instead of keypress . keydown will show the before-keystroke value, as will keypress (apparently). 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 keyup event instead, or use window.setTimeout() to set up a delay. Because the keystroke is not registered until

UITextView hide keyboard in iphone

谁都会走 提交于 2019-11-29 13:28:17
问题 I want to hide keyboard when a user presses return in UITextView object in iphone. However, mysteriously this is not working for UITextView but working for UITextField . I am unable to figure out why... This is what I did: 1) I created a view based application in XCode4. 2) in .xib created UITextView , UITextField and UIButton objects 3) Marked both UITextField and UITextView delegates to File's Owner in Outlets 4) Added <UITextFieldDelegate> to @interface UIViewController in .h 5) Added

Capture the events of 2 or more keyboards in JavaScript/Web Browser

心不动则不痛 提交于 2019-11-29 11:02:35
I am writing some test applications that perform simple keyboard event capture. I have no problem with this basic approach. But now I need a better experience with my application and I want to connect at least two or more USB or PS/2 keyboards, distinguishing what keyboard is the source of the key events, and so being able to use the web browser locally with JavaScript (and HTML5), as if it was a game console with several controllers for more than one player, simultaneously. I know that even under Windows or Linux, the normal behavior is to make several keyboards fire the same events. However,

Alternative for event's deprecated KeyboardEvent.which property

北战南征 提交于 2019-11-29 10:00:22
问题 MDN states that KeyboardEvent.which is deprecated. How can I substitute it for a non-deprecated version? For example, I have the following: window.onkeydown = (event) => { console.log(event.which); } I thought event.key.charCodeAt() could substitute event.which , but this won't work for keys such as ALT , CTRL or ENTER , and it only works if event.key.length === 1 : window.onkeydown = (event) => { console.log(event.key.charCodeAt()); } To recap, event.which != event.code and event.which !=

javascript, simulate keyboard events, work on chrome(webkit)

独自空忆成欢 提交于 2019-11-29 08:39:59
in FF, i've used this code: if (keyCount == lineLimit) { // method in FF, no Chrome var mock = document.createEvent("KeyboardEvent"); // or KeysEvent mock.initKeyEvent("keypress",true,true,null,false,false,false,false,14,0); var x = document.getElementById('InputCategory'); // rise height before Enter $(this).height(div_height + font_height + offset_height); // mock Enter x.dispatchEvent(mock); // init keyCount keyCount = 0; } it works, but could not be effective on webkit-based browsers like chrome. so i asked google and found keyboard event is one of the DOM Level 3 events,here is an aticle:

Page-global keyboard events in Windows Store Apps

主宰稳场 提交于 2019-11-29 07:33:57
问题 I'm working on a game, a Windows Store App based on WPF and written in C#. When the player presses the Esc key, I want to pause the game and show a menu (Continue, Quit etc.). Sounds simple. Sadly, it's not. The game takes place in a Windows.UI.Xaml.Controls.Page and primarily consists of hundreds of Shape s in a Canvas , but no single Button , TextBox or anything else that supports keyboard interaction. The only interaction is clicking or tapping shapes. I need to catch keyboard events,

How can I generate a keyup event with a specific keycode in IE8?

两盒软妹~` 提交于 2019-11-29 04:36:53
I need to generate keyup events in IE 8 using native DOM functions (no jQuery). The following code generates, fires, and receives the event, but the keyCode is always 0. How do I properly pass the keyCode? <form><input id="me" type="submit" /></form> <script type="text/javascript"> var me = document.getElementById("me"); me.attachEvent("onkeyup", function(e) { alert(e.keyCode); // => 0 }); document.getElementById("me").fireEvent('onkeyup', 13); </script> Figured it out. The solution is to create an event object, assign the keycode, and fire it from the node. var e = document.createEventObject(

Is it OK to ignore keydown events with keyCode = 229?

ε祈祈猫儿з 提交于 2019-11-29 04:17:18
问题 At the beginning I wanted to monitor changes to a <input type="text"> in real time (for example, exactly when the user presses a key). The onChange event did not work because it is triggered only when the user presses Enter or removes focus from the input element. Then I saw this question on StackOverflow. I tried the code from that answer but the problem is that I do not want to be notified for key presses that do not represent printable characters, so I had to modify it in this way to make