keydown

Javascript keyup doesn't work as expected, it executes in instances where I have not removed my finger from a button

妖精的绣舞 提交于 2019-12-07 11:53:34
问题 I'm trying to create a simple game in javascript and I'm stuck on how to deal with keys. Small example: function keyUpEvent(event) { alert(event.keyCode); } window.addEventListener("keyup", keyUpEvent, false); I'm running Ubuntu 9.10 and testing it in Firefox 3.5 and Chromium. If I press and release a button instantly I get an alert, which is to be expected, but when I press and hold a button I get a small pause and then a series of alert windows, the expected result is that I only get an

silverlight keydown event doesn't fire for arrow keys

血红的双手。 提交于 2019-12-07 09:59:16
问题 I have a canvas inside a scrollview. I attached a keydown event handler to the scrollview. For most keys, the handler gets called. However, for the arrow keys, the handler does not get called. Instead, the scrollview gets scrolled in the appropriate direction. I also attached a keyup handler to the scrollview and the keyup does get called for the arrow keys. Is there any way to get the arrow key down event here? 回答1: Just use the KeyUp event. Works like a charm. 回答2: I found this silly hack

Keep focus on textbox after pressing enter

蓝咒 提交于 2019-12-07 03:16:38
问题 How can I keep the focus in a textbox after pressing enter in a VBA form? This code adds the text to a Listbox and I want to keep the focus on the textbox to get ready to receive another item. When I click in the button Add, it adds the text to the Listbox and returns the focus to the textbox, howerver when I press enter it doesn't, even tough it uses the same code. Any suggestion? This is my code for the textbox: Private Sub TxtOtherAsset_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal

Basic WinForm KeyDown event handling

泪湿孤枕 提交于 2019-12-06 13:34:44
I'm using WinForms. I've created an event handler for the KeyDown event of the main form, thereby invoking a button's Click event handler. The Click event handler called is dependent upon the specific key pressed. If a user clicks the button rather than using the key, and then subsequently tries to use the key thereafter, the key (down arrow for example) acts as a tab-cycle, changing focus between each button control on the form (rather than executing the Keydown handler). Any ideas ? The problem is, the button has the focus when it is clicked, so subsequent key presses are not caught by the

Detect F5 being pressed and Refresh

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:58:13
I have a webform and i want to detect if F5 button was pressed or if the page was refreshed. I know about postback but it is not what i'm looking for. I have a gridview that loads in a modal popup when a button is clicked and a parameter's value is set for the gridview. When refresh is hit and if the modal popup button was previously clicked the modal popup is visible right after refresh. I want to detect if the page is refreshed to prevent this. any ideas? I thought to try Override but I'm not exactly sure how to use it. I tried Control.ModifierKeys but I don't have access to ModifierKeys.

How can I determine in KeyDown that Shift + Tab was pressed

三世轮回 提交于 2019-12-06 12:23:09
How can I determine in KeyDown that ⇧ + Tab was pressed. private void DateTimePicker_BirthDate_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Tab && e.Modifiers == Keys.Shift) { //do stuff } } can't work, because never both keys are pressed exactly in the same second. You always to at first the Shift and then the other one.. It can't work, because never both keys are pressed exactly in the same second. You're right that your code doesn't work, but your reason is wrong. The problem is that the Tab key has a special meaning - it causes the focus to change. Your event handler is

How do I capture the backspace key in IE8 with jquery?

可紊 提交于 2019-12-06 11:48:45
I've got a simple javascript keydown event coded via jquery. The event should just alert the key that is "down." This works for most keys but not the backspace key in Internet Explorer. I read that IE messes this up on the keypress event but was supposed to work for the keydown and keyup events. Is there anything I can do via jquery to capture the backspace in IE? The version of IE I'm currently testing in is: 8.0.7600.16385 $('.AddressField').bind("keydown", function (e) { alert(e.keyCode); }); use which: $('.AddressField').keypress(function(e){ alert(e.which); }); keyCode property is not

Javascript/Jquery validating decimal input on keypress/keydown

三世轮回 提交于 2019-12-06 07:20:12
I'm trying to find a way to validate a text input on key press, I want to allow numbers only inside my text input including decimals. I was taking the approach of using jQuery.keydown, and checking what the key was and using event.preventDefault() if the key was not in the allowed list. But since then I've read that keys aren't consistent throughout browsers and I'm also worries about different OS's. I've come across this question but I'm not fluent in regex and not sure whether this would suit my needs: jquery - validate characters on keypress? With that approach a regex that expects 00.00

Textarea lags after registering `keydown` events using Javascript

可紊 提交于 2019-12-06 03:49:47
问题 How does one go about attaching a bunch of code to an onkeydown event, but keep entering text into a textarea fast and crisp? Anything more than a couple of IF statements seems to slow it down quite considerably. EDIT : I should add (can't believe I forgot!) that this doesn't affect desktop browsers. It's mainly an issue with iPhone Safari. Other mobile browsers might be affected as well, but we're focusing on iPhone Safari since it executes JS the best (AFAIK) 回答1: Considering your edit

Firefox keydown backspace issue

不想你离开。 提交于 2019-12-06 03:49:46
I'm building a terminal emulation and running into an issue with capturing backspace in Firefox. I'm able to nab the first backspace and remove the last character on the input at the prompt, but it won't persist and remove more than one character. Actual website: http://term.qt.io/ Replication here: http://jsfiddle.net/BgtsE/1/ JavaScript code function handleKeys(e){ var evt = e || window.event; var key = evt.charCode || evt.keyCode; if(evt.type == "keydown") { curr_key = key; if(key == 8) { evt.preventDefault(); if(0 < $('body').text().length) $('body').text($('body').text().slice(0,-1)); } }