keyboard-events

Can I disable keyboard input to a specific control?

♀尐吖头ヾ 提交于 2019-12-05 14:27:56
Is it possible to disable keyboard input to a control? For instance a ListView ? How do I do that? I've tried overriding the KeyUp KeyDown events but apparently that was not the way? IsEnabled is a good solution, however I only wish to disable keyboard interaction and leave mouse interaction intact. John Myczek Handling the KeyDown event is too late, but you can handle the PreviewKeyDown event and that should give you the behavior you are looking for: private void MyListBox_PreviewKeyDown(object sender, KeyEventArgs e) { e.Handled = true; } Dear maciek, the only thig you need to do is using

SendInput() and non-English characters and keyboard layouts

心不动则不痛 提交于 2019-12-05 12:43:51
I'm having trouble simulating character keypresses when a non-English input keyboard language is being used in Windows. I tried calling SendInput() with KEYEVENTF_UNICODE: KEYBDINPUT ki; INPUT input; int character = 0; ki.wVk = 0; ki.wScan = character; ki.dwFlags = KEYEVENTF_UNICODE; ki.time = 0; ki.dwExtraInfo = 0; input.type = INPUT_KEYBOARD; input.ki = ki; SendInput(1, &input, sizeof(INPUT)); And this actually works (of course, in my code, I also do a KEYUP after the key down)... except in GTK+ apps (there may be other instances where it doesn't work either). According to MSDN , If

Capturing modifier keys Qt

不羁的心 提交于 2019-12-05 07:56:48
I am trying to understand how to handle various events with Qt and have found an issue I cannot understand with key modifiers e.g. Ctrl Shift Alt etc. I have made a default Qt GUI Application in Qt Creator extending QMainWindow and have found that the following example does not produce understandable results. void MainWindow::keyPressEvent(QKeyEvent *event) { qDebug() << "Modifier " << event->modifiers().testFlag(Qt::ControlModifier); qDebug() << "Key " << event->key(); qDebug() << "Brute force " << (event->key() == Qt::Key_Control); } Using the modifiers() function on the event never is true

JavaScript keypress event get end value of textarea

我的未来我决定 提交于 2019-12-05 04:31:23
I was wondering if it were possible to get the end result in the keypress event? Currently, I am using the keyup because it is activated after the user has done text editing in a texteara, but I have written a method that does something similar using the Mootools library: input.addEvent("keypress", function (input) { var previous_result = this.value; var end_result = this.value + input.key; }); However, this method is horrible when dealing with special keys such as backspace, or if the user chooses to use CTRL + a && Backspace in which case the value of the input element would not be "an empty

Getting notified when user presses “Search” on keyboard in UISearchDisplayController

允我心安 提交于 2019-12-05 02:37:11
I am using a UISearchDisplayController to let the user search through a list of buildings on a university campus. Sometimes, the user will know exactly what building they want, enter the building's number, and that building will then be the only building result showing in the UITableView. At the moment, if the user proceeds to hit "Search" on the keyboard, the keyboard animates off the screen and the user then has to make a second tap on the sole item in the UITableView to be sent to a point on a map showing the location of that building. My question is, is there a way to be notified when the

CGEventPost - hold a key (shift)

大憨熊 提交于 2019-12-05 02:18:26
I'm looking for a way to design a little panel with modifier keys on it (shift, command for example) and have to possibility to click on it like a virtual keyboard. I'd like it to have this behavior : click on the virtual key (shift). the shift button holds, and keeps being pressed. type something with my standard keyboard. click another time on the virtual shift key to release it. here is the code I'm using : CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef shiftKeyDown = CGEventCreateKeyboardEvent(source, (CGKeyCode)56, YES); CGEventRef shiftKeyUp

fabric.js canvas listen for keyboard events?

怎甘沉沦 提交于 2019-12-05 00:50:22
In my fabric application, I'm currently listening for certain key presses such as the delete key, and deleting any selected elements. My method of listening for key presses is: document.onkeydown = function(e) { if (46 === e.keyCode) { // 46 is Delete key // do stuff to delete selected elements } I'm running into a problem though: I have other elements like text boxes on the page, and when typing in a text box, I don't want the delete key to delete any elements. In this question , there's a method described to attach an event listener to an HTML5 canvas: canvas.tabIndex = 1000; allows you to

Physical Key State

◇◆丶佛笑我妖孽 提交于 2019-12-04 20:46:40
The two key-state functions in the WIndows API, GetKeyState() and GetAsyncKeyState() , both determine key state based on key up/down messages rather than the physical state of the key. I am working on a program which manipulates input, using SendInput() , to release modifier keys (alt, ctrl, etc...), send input, and then re-press the modifier keys. The problem is that I don't know if the modifier keys are still pressed after the input is sent because I have sent the key-up event and both of the above mentioned functions return that the key is up regardless of the state of the physical key. So

Choose and select div elements with keyboard arrows and enter keys?

旧巷老猫 提交于 2019-12-04 19:40:16
Is there any way of navigating through a grid of div elements by pressing the arrow keys on the keyboard, and "clicking" the selected div by pressing enter key? I know that I should at least try to make this work somehow but I'm completely clueless as for how to make this happen, and if it's even possible. I'm aware of that the following will be invalid if not using the mouse, so what can I do to show some kind of "focus" on a specific div? .show:hover{ width:94px; height:94px; border:3px solid black; } .lock{ pointer-events:none; } Any hints of where to start? My game's here: http://jsfiddle

Listen for keyboard events and mouse movement outside of Electron app

倖福魔咒の 提交于 2019-12-04 17:43:16
问题 I've been getting into a few Electron projects and I am trying to figure out how you could listen for any keypresses or and track mouse movement when the app is in the background. I am using the menubar plugin so the app is still running in the background. I tried using the global-shortcut API but it looks like that is for shortcuts only and you can't register individual keystrokes. I've also looked over the API and have yet to find an event for keystrokes and mouse movements outside the app