keydown

C# trying to capture the KeyDown event on a form

白昼怎懂夜的黑 提交于 2019-11-27 13:56:20
I am creating a small game, the game is printed onto a panel on a windows form. Now i want to capture the keydown event to see if its the arrow keys that has been pressed, the problem however is that i can't seem to capture it. Let me explain, on the form i have 4 buttons and various other controls and if the user for instance press one of the buttons (to trigger a game event) then the button has focus and i can't capture the movements with the arrow keys. I tried something like private void KeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Left) { game.MovePlayer(DonutWarsLibrary.GameObjects

tabindex in CSS

喜欢而已 提交于 2019-11-27 13:25:12
问题 Is it possible to control tabindex with CSS and if yes, which browsers support it and on which elements? EDIT I should say, my goal is to catch keydown events on a div. I saw this page http://www.quirksmode.org/js/events/keys.html# that tests keyboard events and it shows that the only way keydown fires on anything other than document and body or some kind of form element or link is to have tabindex declared on it. But I read on W3C site: The following elements support the tabindex attribute:

How to decode character pressed from jQuery's keydown()'s event handler

余生长醉 提交于 2019-11-27 11:11:06
I need to figure out which character was typed into a text field from within the handler that is called by jQuery's keydown function. key.which gives me only the keycode, but I need to figure out which ASCII character key represents. How do I do this? For character input, it is suggested you use keypress() , which will report the actual ASCII code for the character pressed. It automatically takes care of letter case, and ignores non-character presses. In either case, you can use fromCharCode() to convert to a string representation. E.g. var c = String.fromCharCode(e.which) // or e.keyCode Just

Removing the delay after KeyDown event?

可紊 提交于 2019-11-27 09:47:56
When I hold a key in my game to move my player: public void MainForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { Player.MoveUp(); } } The player instantly moves one step as soon as I press the down arrow, and then pauses for a short duration before starting to smoothly move again. Why's this? How can I prevent it? Peter Duniho The answer in the proposed duplicate is incorrect, unfortunately. It doesn't ignore repeated KeyDown events, and so will gradually increase the "delta" value in the direction being handled by each key case. It also doesn't respond to the keypress

How to trigger key combo with jQuery

拈花ヽ惹草 提交于 2019-11-27 09:31:48
I have coded some stuff: http://fincha.com/kunden/schmitt/ I zoom in with .css("zoom") but I need the buttons to simulate CTRL + or CTRL - This code isn't working for me: e = jQuery.Event("keydown"); e.which = 50; $("input").trigger(e); Please help! EDIT I actually wanted to zoom-in and zoom-out the whole web page, not just a input field. Matt Ball jQuery normalizes modifier keys on events by setting one or more properties on the event object. So, you want to set event.ctrlKey to true , so this should work for you: e = jQuery.Event("keydown"); e.which = 50; e.ctrlKey = true; $("input").trigger

How to use multiple modifier keys in C#

陌路散爱 提交于 2019-11-27 09:12:03
I am using a keydown event to detect keys pressed and have several key combinations for various operations. if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control && e.Modifiers == Keys.Shift) { //Do work } else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) { //Paste } For some reason the key combination in which I hit Ctrl + Shift + C is not working. I have re ordered them, and placed it at the top thinking it might be interference from the Ctrl + C , and even removed the Ctrl + C to see if it was causing a problem. It still does not work. I know it's probably something very simple,

Adding event handler to an iframe using JQuery

一个人想着一个人 提交于 2019-11-27 09:06:59
I want to assign a keydown event handler to an iframe. Something similar to the pure JS: document.getElementById('iframe_id').contentWindow.addEventListener('keydown',funcName, true); I tried: $(document.getElementById('iframe_id').contentWindow).keydown( function() { // my func }); But it does not work.. Please help! contentWindow is the iframe 's window object. You want the iframe 's document instead: $(document.getElementById('iframe_id').contentWindow.document).keydown(function() { // my func }); Note that I am not sure how jQuery reacts to elements from other windows/frames. Just

Capturing keydown event of MS Word

☆樱花仙子☆ 提交于 2019-11-27 08:38:54
问题 I want to capture the backspace event, just do the backspace's action, then add other action, but I am not sure the backspace's original action:Selection. Delete , -1 ? Sub AddKeyBinding() With Application ' \\ Do customization in THIS document .CustomizationContext = ThisDocument ' \\ Add keybinding to this document Shorcut: Backspace .KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyBackspace), _ KeyCategory:=wdKeyCategoryCommand, Command:="TestKeybinding" End With End Sub ' \\ Test sub for

Get the char on Control.KeyDown?

左心房为你撑大大i 提交于 2019-11-27 07:45:14
问题 When handling Control.OnKeyPress event, there is a KeyPressEventArgs that contains a KeyChar . For usability reasons I need exactly the same KeyChar but when handling OnKeyDown event. The KeyEventArgs does not contains any char related data. I mean, if press the A key with or without Shift its not affecting the KeyCode , KeyData or KeyValue . The same when using another language, i still getting capital english values. How to get a KeyPressEventArgs.KeyChar inside KeyDown event? Thanks. 回答1:

Detect CTRL and SHIFT key without keydown event?

Deadly 提交于 2019-11-27 06:58:07
问题 I've been wondering if I can detect CTRL and SHIFT key being pressed WITHOUT using keydown event. The reason is that I am creating some sort of Grid Viewer in JavaScript, and I implemented selecting different items by holding CTRL or SHIFT key as it functions in most common viewers, editors and so on. The problem is that when the focus is not anywhere on the page. For example I'm adding page to the bookmarks. Then I hold CTRL or SHIFT and click on the item, but it acts normally as keydown