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
    I’m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

  • By
    Write Better JavaScript with Promises

    You've probably heard the talk around the water cooler about how promises are the future. All of the cool kids are using them, but you don't see what makes them so special. Can't you just use a callback? What's the big deal? In this article, we'll...

Incredible Demos

  • By
    jQuery Countdown Plugin

    You've probably been to sites like RapidShare and MegaUpload that allow you to download files but make you wait a specified number of seconds before giving you the download link. I've created a similar script but my script allows you to animate the CSS font-size...

  • By
    Check All/None Checkboxes Using MooTools

    There's nothing worse than having to click every checkbox in a list. Why not allow users to click one item and every checkbox becomes checked? Here's how to do just that with MooTools 1.2. The XHTML Note the image with the ucuc ID -- that...

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!