Posted By

cfleschhut on 04/23/10


Tagged

javascript events mootools custom


Versions (?)

MooTools Custom Events


 / Published in: JavaScript
 

URL: http://jsfiddle.net/Qp2MM/

  1. /* Example 1: Alt-Click on div#foo */
  2. Element.Events.altClick = {
  3. base: "click",
  4. condition: function(e) {
  5. return e.alt;
  6. }
  7. };
  8. var clicks = 0;
  9. $("foo").addEvent("altClick", function(e) {
  10. clicks++;
  11. this.set("text", clicks);
  12. });
  13.  
  14. /* Example 2: Shift-H Shortcut */
  15. Element.Events.shiftH = {
  16. base: "keypress",
  17. condition: function(e) {
  18. if (e.shift && e.key == "h") { return true; }
  19. }
  20. };
  21. window.addEvent("shiftH", function() {
  22. var div = $("foo");
  23. var opacity = (div.get("opacity") == 0 ? 1 : 0);
  24. div.tween("opacity", opacity);
  25. });

Report this snippet  

You need to login to post a comment.