Posted By

chrisaiv on 02/28/07


Tagged

keylogger as2


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Roshambo
n00ge
yeco
emilymer


AS2: Up, Up, Down, Down, Left, Right, Left, Right for Flash


 / Published in: ActionScript
 

I wanted to put the famous Konami - Contra easter egg in my flash game (up up down down left right left right). Here's how i did it.

  1. var keyListener:Object = new Object();
  2. var isCtrlKeyPressed:Boolean = false;
  3. var keyPressCount:Number = 0;
  4. var keyCombination:String = "";
  5. var keyCode:String = "";
  6. var lasPressedKeyCode:String = "";
  7. keyListener.onKeyDown = function() {
  8. keyPressCount++;
  9. if (keyPressCount >= 9) {
  10. keyPressCount = 1;
  11. if (isCtrlKeyPressed == true) {
  12. keyCombination = "17";
  13. } else {
  14. keyCombination = lasPressedKeyCode;
  15. }
  16. }
  17. keyCode = "" + Key.getCode();
  18. keyCombination += keyCode;
  19. trace(keyCombination);
  20. if (Key.isDown(17) == true) {
  21. isCtrlKeyPressed = true;
  22. } else {
  23. isCtrlKeyPressed = false;
  24. }
  25. if (keyCombination == "3838404037393739") {
  26. trace("YESSSS copied :) : " + keyCombination);
  27. }
  28. if (keyCombination == "1786" && isCtrlKeyPressed == true) {
  29. trace(output_03.text = "YESSSS pasted :) : " + keyCombination);
  30. }
  31. if (keyCombination == "1788" && isCtrlKeyPressed == true) {
  32. trace(output_03.text = "YESSSS cut :) : " + keyCombination);
  33. }
  34. lasPressedKeyCode = keyCode;
  35. };
  36. Key.addListener(keyListener);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Roshambo on May 23, 2007

Brilliant! Thanks for this!

You need to login to post a comment.