onkeyup

onkeydown and onkeyup events don't work on Internet Explorer 8

拈花ヽ惹草 提交于 2019-12-07 12:24:36
问题 My code works without problems on IE9/IE10, FF, Chrome and opera but on older Internet Explorer no Keyboard input is handled. I have the following code for handling events. It should only fire when a new button is pressed. lastEvent = void 0; heldKeys = {}; window.onkeydown = function(event) { if (lastEvent && lastEvent.keyCode === event.keyCode) { return; } lastEvent = event; heldKeys[event.keyCode] = true; switch (event.which) { case 80: return myamp.userInput("positiv"); case 81: return

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

Caching DOM elements

对着背影说爱祢 提交于 2019-12-07 09:40:27
When I have a DOM elements that are accessed many times in event handlers but not consecutively in code, is it benefical to store them in a variable? Examples- I have an event handler set for onresize - in the handler I get elements by ID's. As I know, this event is triggered multiple times when window is resized, so would it be better to hold a reference to these elements in global variables? I implement an AJAX based search. I have an input-text element and I've set handler for onkeyup event. In the handler I need to get some elements by ID to set the result, and also to hide and show (css)

Cmd Enter keyup combination detection using javascript

谁都会走 提交于 2019-12-06 14:29:24
问题 I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted. But now I want to detect the Cmd + Enter combination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like? Thank you 回答1: You mean ctrl with Cmd ? Then check if event.ctrlKey is true: if (event.ctrlKey && event.keyCode ==

WP8 : IExplorer 10 : on “keyup” event not firing for “RETURN” key

喜你入骨 提交于 2019-12-06 12:01:52
I've just came across this interesting problem, or probably it's just me missing something very basic (hopefully). The problem is, that the keyup event is not firing for the return key in the WP8 browser, whereas all the other standard keys are firing this event up. I've tested this on the desktop, and IE10 is not having any issues with this, the event fires up nicely. Can anyone else confirm that on their WP8 devices the keyup event is not being triggered for the "return" key ? /using dojo syntax here/ on(dom.byId("testinput1"), "keyup", function(evt){ dom.byId("result1").innerHTML = ""; if

ckeditor onKeyUp event how?

北城以北 提交于 2019-12-06 06:06:41
This code piece must copy text from textarea text to textarea text_hidden , this code work without ckeditor onKeyUp="document.getElementById('text_hidden').value = this.value; but when ckeditor enabled onKeyUp="document.getElementById('text_hidden').value = this.value; not work. How to fix this ? <textarea name="text" id="text" rows="6" cols="80" onKeyUp="document.getElementById('text_hidden').value = this.value;" ></textarea></p> <textarea name="text_hidden" id="text_hidden" rows="6" cols="80" ></textarea> <script> CKEDITOR.replace( 'text' , { allowedContent: true, enterMode: CKEDITOR.ENTER

Trigger Change event and keyup event in select element

元气小坏坏 提交于 2019-12-05 22:51:09
问题 I have some codes that should be run when a select element changes.I do it with jquery in this way: $("#myselect").change(function() { ....... }); But I want these codes run also when user change the select using keyword arrows. As i found the event for this purpose is 'keyup' . So will be : $("#myselect").keyup(function() { ....... }); How can i combine these two event? 回答1: You can use .bind() to combine them: $("#myselect").bind("change keyup", function(event){ //Code here }); See

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

╄→尐↘猪︶ㄣ 提交于 2019-12-05 21:54:58
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 alert window when I remove my finger from a button. I reason it has something to do with the fact that

Angular 2+ elegant way to intercept Command+S

大兔子大兔子 提交于 2019-12-05 18:06:13
问题 Trying to implement a shortcut key combination for Command+S to save a form. I've read this - https://angular.io/guide/user-input, but it does not say anything about meta or command. Tried surrounding the form with: <div (keyup.command.s)="save()" (keyup.command.u)="save()" (keyup.control.u)="save()" (keyup.control.s)="save()" (keyup.meta.u)="save()" > Of those, only control.u and control.s worked. With all the power and cross-browser capabilities of Angular 2+, I was hoping that this is

Can I delay the keyup event for jquery?

天涯浪子 提交于 2019-12-05 01:12:09
I'm using the rottentomatoes movie API in conjunction with twitter's typeahead plugin using bootstrap 2.0. I've been able to integerate the API but the issue I'm having is that after every keyup event the API gets called. This is all fine and dandy but I would rather make the call after a small pause allowing the user to type in several characters first. Here is my current code that calls the API after a keyup event: var autocomplete = $('#searchinput').typeahead() .on('keyup', function(ev){ ev.stopPropagation(); ev.preventDefault(); //filter out up/down, tab, enter, and escape keys if( $