keyboard-events

C++ console keyboard events

天大地大妈咪最大 提交于 2019-11-27 05:34:29
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. 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 that is owned by code in Windows and a message pump, also owned by code in Windows. You can get the window

Python cross-platform listening for keypresses? [duplicate]

自作多情 提交于 2019-11-27 04:49:24
This question already has an answer here: Python read a single character from the user 20 answers 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)? or is there a way to use just the event system from tkinter, pygame, etc...? If not, how should I approach tackling this? My

change keyboard layout with javascript

懵懂的女人 提交于 2019-11-27 03:21:28
问题 I have a html form. Users can fill in the form in both english and persian languages. but I have a captcha input that users should fill it in english. If the user's keyboard layout is persian what is typed in this field should change to english so I need some coded that change the keyboard layout on focusing on this input text. Is it possbile to change keyboard layout with javascript?? 回答1: You won't be able to change the keyboard layout using JS, but you can capture the keydown event and

Send mouse & keyboard events

南笙酒味 提交于 2019-11-27 02:51:48
问题 I'm developing an app that have to send some keys or mouse events to the active window. I'm using this class: Mouse using System.Runtime.InteropServices; using System.Windows.Forms; namespace Mouse { public static class VirtualMouse { // import the necessary API function so .NET can // marshall parameters appropriately [DllImport("user32.dll")] static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); // constants for the mouse_input() API function private

NSNotificationCenter Swift 3.0 on keyboard show and hide

懵懂的女人 提交于 2019-11-27 02:45:10
问题 I am trying to run a function when the keyboard shows and disappears and have the following code: let notificationCenter = NotificationCenter.default notificationCenter.addObserver(self, selector: #selector(ViewController.keyBoardUp(Notification :)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) And the function keyBoardUp below: func keyBoardUp( Notification: NSNotification){ print("HELLO") } However the function doesn't print to the console when the keyboard shows. Help would

Trigger a keyboard key press event without pressing the key from keyboard

£可爱£侵袭症+ 提交于 2019-11-27 02:22:27
问题 How can I trigger a key press event without pressing the key from Keyboard? I tried with the solution from here, but I got the following exception: The best overloaded method match for 'System.Windows.PresentationSource.FromVisual(System.Windows.Media.Visual)' has some invalid arguments. Consider Shift+A contains 2 key press event from keyboard,how can I do it without keyboard pressing?(let, just print capital A in a textbox on a button click) My code var key = Key.A; // Key to send var

Hitting Tab in Visual Studio selects block instead of adding indentation

只愿长相守 提交于 2019-11-27 02:06:59
问题 I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly: When the cursor is inside of any word inside the line, hitting the Tab-key selects the word or block. But the desired behavior would be to indent at the cursor (e.g. split a word into two words, if the cursor was inside of the word Stream after the letter r): Does

How to get a combination of keys in c#

流过昼夜 提交于 2019-11-27 02:06:04
How can I capture Ctrl + Alt + K + P keys on a C# form? thanks It is a chord, you cannot detect it without memorizing having seen the first keystroke of the chord. This works: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private bool prefixSeen; protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (prefixSeen) { if (keyData == (Keys.Alt | Keys.Control | Keys.P)) { MessageBox.Show("Got it!"); } prefixSeen = false; return true; } if (keyData == (Keys.Alt | Keys.Control | Keys.K)) { prefixSeen = true; return true; } return base.ProcessCmdKey

How to prevent number input on keydown?

梦想的初衷 提交于 2019-11-27 01:53:19
问题 I want to prevent number input on keydown event on textfield and run custom handler function. Here are the issues e.target.value is useless since the key value is not projected into the target value yet e.keyCode for number depends on keyboard type, language layout, Fn or Shift key String.fromCharCode(e.keyCode) is not reliable, at least on my keyboard (Czech qwerty) w3 specification says e.keyCode is a legacy attribute and suggests e.char instead, but it is not implemented in browsers yet So

Android EditText, soft keyboard show/hide event?

筅森魡賤 提交于 2019-11-27 00:53:51
Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText? woodshy 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){ // Keyboard is shown } else { // Keyboard is hidden } super.onMeasure(widthMeasureSpec,