keyboard-events

Python cross-platform listening for keypresses? [duplicate]

流过昼夜 提交于 2019-11-26 11:21:52
问题 This question already has answers here : Python read a single character from the user (22 answers) Closed 5 years ago . I need to listen for certain keypresses in a python terminal program without pausing execution with raw_input . I\'ve seen people use a few windows specific ways of listening for keystrokes and I\'ve seen people use large modules like tkinter and pygame which I want to avoid. Is there a lightweight module out there that does this cross platform (at least ubuntu, windows, mac

Android EditText, soft keyboard show/hide event?

牧云@^-^@ 提交于 2019-11-26 09:32:44
问题 Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText? 回答1: Hi I'd used following workaround: As far as my content view is a subclass of LinearLayout (could be any other view or view group), I'd overridden onMeasure method lilke following: @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int proposedheight = MeasureSpec.getSize(heightMeasureSpec); final int actualHeight = getHeight(); if (actualHeight > proposedheight){ //

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

∥☆過路亽.° 提交于 2019-11-26 08:29:36
问题 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

How to handle key press event in console application

假如想象 提交于 2019-11-26 05:17:59
I want to create a console application that will display the key that is pressed on the console screen, I made this code so far: static void Main(string[] args) { // this is absolutely wrong, but I hope you get what I mean PreviewKeyDownEventArgs += new PreviewKeyDownEventArgs(keylogger); } private void keylogger(KeyEventArgs e) { Console.Write(e.KeyCode); } I want to know, what should I type in main so I can call that event? For console application you can do this, the do while loop runs untill you press x public class Program { public static void Main() { ConsoleKeyInfo keyinfo; do { keyinfo

How to handle key press event in console application

╄→гoц情女王★ 提交于 2019-11-26 01:54:23
问题 I want to create a console application that will display the key that is pressed on the console screen, I made this code so far: static void Main(string[] args) { // this is absolutely wrong, but I hope you get what I mean PreviewKeyDownEventArgs += new PreviewKeyDownEventArgs(keylogger); } private void keylogger(KeyEventArgs e) { Console.Write(e.KeyCode); } I want to know, what should I type in main so I can call that event? 回答1: For console application you can do this, the do while loop

How to generate keyboard events in Python?

守給你的承諾、 提交于 2019-11-26 00:39:56
问题 short summary: I am trying to create a program that will send keyboard events to the computer that for all purposes the simulated events should be treated as actual keystrokes on the keyboard. original post: I am looking for a way to generate keyboard events using python. Assume that the function receives a key that it must simulate pressing, like so: keyboardevent(\'a\') #lower case \'a\' keyboardevent(\'B\') #upper case \'B\' keyboardevent(\'->\') # right arrow key def keyboardevent(key):

Detecting arrow key presses in JavaScript

天涯浪子 提交于 2019-11-26 00:14:02
问题 How do I detect when one of the arrow keys are pressed? I used this to find out: function checkKey(e) { var event = window.event ? window.event : e; console.log(event.keyCode) } Though it worked for every other key, it didn\'t for arrow keys (maybe because the browser is supposed to scroll on these keys by default). 回答1: arrow keys are only triggered by onkeydown , not onkeypress keycodes are: left = 37 up = 38 right = 39 down = 40 回答2: On key up and down call function. There are different

Firing a Keyboard Event in Safari, using JavaScript

99封情书 提交于 2019-11-26 00:06:58
问题 I\'m trying to simulate a keyboard event in Safari using JavaScript. I have tried this: var event = document.createEvent(\"KeyboardEvent\"); event.initKeyboardEvent(\"keypress\", true, true, null, false, false, false, false, 115, 0); ...and also this: var event = document.createEvent(\"UIEvents\"); event.initUIEvent(\"keypress\", true, true, window, 1); event.keyCode = 115; After trying both approaches, however, I have the same problem: after the code has been executed, the keyCode / which