Listen for the Delete Key Using MooTools

By  on  

I saw an interesting ticket hit the MooTools Lighthouse system recently. A user reported that they could not use the following code snippet to listen for the delete key:

var isdel = Event.Keys.delete;

While that generally works, it does not work for the delete key because "delete" is a reserved word. Instead, you must listen for the delete key with this code snippet:

var isdel = Event.Keys['delete'];

Very interesting. As flexible as Moo's language is, you can't get around the reserved words!

Recent Features

  • By
    Page Visibility API

    One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?

  • By
    6 Things You Didn’t Know About Firefox OS

    Firefox OS is all over the tech news and for good reason:  Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript.  Firefox OS has been rapidly improving...

Incredible Demos

  • By
    FileReader API

    As broadband speed continues to get faster, the web continues to be more media-centric.  Sometimes that can be good (Netflix, other streaming services), sometimes that can be bad (wanting to read a news article but it has an accompanying useless video with it).  And every social service does...

  • By
    Fading Links Using jQuery:  dwFadingLinks

    UPDATE: The jQuery website was down today which caused some issues with my example. I've made everything local and now the example works. Earlier this week, I posted a MooTools script that faded links to and from a color during the mouseover and mouseout events.

Discussion

  1. mootools rules! :)

  2. Thanks for keeping us informed, David!

  3. Hugo

    I saw an interesting ticket hit the MooTools Lighthouse system…

    So did you let them know about your solution? :D
    Or did they already take care of that in the docs?

    (not to sound like a jack*ss, of course, just curious)

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!