keyboard-events

Tkinter tkMessageBox disables Tkinter key bindings

非 Y 不嫁゛ 提交于 2019-12-06 15:28:38
Here's a very simple example: from Tkinter import * import tkMessageBox def quit(event): exit() root = Tk() root.bind("<Escape>", quit) #tkMessageBox.showinfo("title", "message") root.mainloop() If I run the code exactly as it is, the program will terminate when Esc is hit. Now, if I un-comment the tkMessageBox line, the binding is "lost" after closing the message box, i.e. pressing Esc won't do anything anymore. This is happening in Python 2.7. Can you please verify if this is happening also to you? And let me know about your Python version. Here is a way to "by-pass" the problem. It's a

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

血红的双手。 提交于 2019-12-06 13:44:50
问题 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

How to simulate Caps Lock keystroke with CGEventCreateKeyboardEvent in OS X

扶醉桌前 提交于 2019-12-06 10:29:47
问题 Has anyone had any luck simulating Caps Lock keystroke with CGEventCreateKeyboardEvent on OS X? Basically I have tried alphabetic character and alphanumeric character okay but Caps Lock. Hopefully, I would like to simulate Caps Lock keystroke to trun on/off the LED. I don't know what problem is for my test code. Has anyone had experinces for this? #include <stdio.h> #include <ApplicationServices/ApplicationServices.h> main() { bool wasCapsLockDown = CGEventSourceKeyState

Combining keycode events in jQuery

大兔子大兔子 提交于 2019-12-06 07:39:07
I'm building a virtual keyboard in jQuery, using keycode events to tigger an append, but keycode combinations are throwing me for a loop. Here's an example: I want to append a questionmark only when both the SHIFT key (keycode 16) and slash key (keycode 191) are pressed together. I thought the && operator would help, but this only appends the slash: $(document).keydown(function(e) { if (e.keyCode == 16 && e.keyCode == 188 ) { $('#mydiv').append('<span>?</span>'); } }); Any suggestions or idea why && isn't working, and what might work? Thanks! Checking e.keyCode == 16 && e.keyCode == 188 won't

Emulate / send Modifier Key (Cntrl, Alt, fn, Shift) in OSx

梦想的初衷 提交于 2019-12-06 04:28:28
I am sending keyboard key press and key release events, which works for all keyboard keys. But modifier keys works only when the key associated with modifier key is sent from application, and not from real hardware. That is if I send Shift and 'a' from application, it prints 'A' (capital A, which is what is expected). But if I send 'shift' key down event from application, and enter 'a' from physical keyboard, it prints 'a' (the shift key doesn't seem to be working across different devices). The same applies for other modifier keys such as cmd, alt, and fn keys!. Is there a way to send modifier

drop/rewrite/generate keyboard events under Linux

别来无恙 提交于 2019-12-05 22:28:21
问题 I would like to hook into, intercept, and generate keyboard (make/break) events under Linux before they get delivered to any application. More precisely, I want to detect patterns in the key event stream and be able to discard/insert events into the stream depending on the detected patterns. I've seen some related questions on SO, but: either they only deal with how to get at the key events (key loggers etc.), and not how to manipulate the propagation of them (they only listen, but don't

On CTRL+MOUSEWHEEL event

我与影子孤独终老i 提交于 2019-12-05 20:25:51
I was asked to implement ctrl+mousewheel event for our page site in order to change image offset on user zoom in or zoom out. I found this old answer Override browsers CTRL+(WHEEL)SCROLL with javascript and I`ve tried to do the same. I downloaded the jQuery Mouse Wheel Plugin for the implementation and here is my code: var isCtrl = false; $(document).on('keydown keyup', function(e) { if (e.which === 17) { isCtrl = e.type === 'keydown' ? true : false; } }).on('mousewheel', function(e, delta) { // `delta` will be the distance that the page would have scrolled; // might be useful for increasing

Detect MS Surface Virtual Keyboard in Javascript

时光怂恿深爱的人放手 提交于 2019-12-05 17:55:27
Is there a way to detect when the virtual keyboard of the MS Surface is being displayed in a web page via Javascript. The virtual keyboard is covering up the active text field on a page, and I need to be able to detect this so that I can re-layout the page to work better with the remaining window area. 来源: https://stackoverflow.com/questions/29997889/detect-ms-surface-virtual-keyboard-in-javascript

C++ Console app, SetWindowsHookEx, Callback is never called

血红的双手。 提交于 2019-12-05 17:42:11
I have a little console application that has an embedded v8 engine, and I would like to add a hook to register key events. This all worked before when I was using Qt and QtScript, but I am porting it all over to straight C++ in VC++ 2008. The application compiles and runs, but the hook is never called, here is the relevant code: In main() HWND hwndC = GetConsoleWindow() ; HINSTANCE hInst = (HINSTANCE)GetWindowLong( hwndC, GWL_HINSTANCE ); if (SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, hInst, NULL) == 0) { printf("Failed to set hook\n"); } else { printf("Hook established\n"); } g->RunScript

How to hook IE keyboard event?

自闭症网瘾萝莉.ら 提交于 2019-12-05 15:06:09
I am trying to disable browser shortcuts while user tries to press some combination of keys on the swf file. Although I can achieve this in Firefox, below code does not function in IE 8. Below code is able to hook the keyboard events if focus is not on the swf file. However, what I need is hooking keyboard events when user operates on swf file. function hookKeyboardEvents(e) { alert("hooked key"); // get key code var key_code = (window.event) ? event.keyCode : e.which; // case :if it is IE event if (window.event) { if (!event.shiftKey && !event.ctrlKey && !event.altKey) { window.event