What’s the easiest way to find the keycode for a specific key press? Are there any good online tools that just capture any key event and show the code? I want to try and find the key codes for special keys on a mobile device with a web browser, so an online tool would be great. Answer Here’s your online
Tag: events
JavaScript add events cross-browser function implementation: use attachEvent/addEventListener vs inline events
In order to add events we could use this simple first solution: or this second solution (that adds inline events): These are both cross-browsers and can be used in this way: Since I have the feeling attachEvent/addEventListener are used more around in events handling implementations, I’m wondering: Are there any disadvantages/drawbacks against using the second solution that I might better
Remove key press delay in Javascript
I have the following problem: I’m trying to write a Javascript game, and the character is being controlled by the arrow keys. The problem is, when one keeps the key pressed, there is a short delay between firing the first keypress and the repeated keypress. Also, when one presses the “right arrow key” and keeps it pressed, and then presses
Add onclick event to newly added element in JavaScript
I have been trying to add onclick event to new elements I added with JavaScript. The problem is when I check document.body.innerHTML I can actually see the onclick=alert(‘blah’) is added to the new element. But when I click that element I don’t see the alert box is working. In fact anything related to JavaScript is not working.. here is what
jQuery hover(): mouseout does not fire when using overflow:auto (with scrollbars)
I’m using jQuery’s hover() helper to attach some behavior to <li> elements in a <ul> with max-height and overflow:auto CSS properties. When the height of the <ul> goes beyond max-height and the vertical scrollbar appears, hovering over the <li> elements triggers mouseOver, but if I move to the right to the scrollbar and start scrolling with the mouse, the mouseOut
Catch browser’s “zoom” event in JavaScript
Is it possible to detect, using JavaScript, when the user changes the zoom in a page? I simply want to catch a “zoom” event and respond to it (similar to window.onresize event). Thanks. Answer There’s no way to actively detect if there’s a zoom. I found a good entry here on how you can attempt to implement it. I’ve found
Detecting when Iframe content has loaded (Cross browser)
I’m trying to detect when an iframe and its content have loaded but not having much luck. My application takes some input in text fields in the parent window and updates the iframe to provide a ‘live preview’ I started with the following code (YUI) to detect when the iframe load event occurs. ‘preview-pane’ is the ID of my iframe
jQuery mouseout firing when injecting child element
I’m trying to create a function which will add an overlay to a thumbnail image when you hover over it and remove the overlay when you leave it. Here is my HTML… And here is my jQuery… The trouble is that when the overlay is created the mouse is already over it and that triggers the “mouseout” of the container,
Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser
I want to handle F1-F12 keys using JavaScript and jQuery. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Explorer 8, Google Chrome and Mozilla FireFox 3. Any suggestions to a full cross-browser solution? Something like a well-tested jQuery library or maybe just vanilla
Event binding on dynamically created elements?
This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.