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
    Welcome to My New Office

    My first professional web development was at a small print shop where I sat in a windowless cubical all day. I suffered that boxed in environment for almost five years before I was able to find a remote job where I worked from home. The first...

  • By
    Camera and Video Control with HTML5

    Client-side APIs on mobile and desktop devices are quickly providing the same APIs.  Of course our mobile devices got access to some of these APIs first, but those APIs are slowly making their way to the desktop.  One of those APIs is the getUserMedia API...

Incredible Demos

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!