Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function Polite() {
  2.  
  3. this.press = "Such pressing";
  4. this.release = "and what a nice release!"
  5.  
  6.  
  7. this.greet = function(d) {
  8.  
  9. if (d == "press") {
  10.  
  11. console.log(this.press);
  12.  
  13. } else if (d == "release") {
  14.  
  15. console.log(this.release);
  16.  
  17. };
  18. };
  19.  
  20.  
  21. this.route = function(e) {
  22. if (e.type == "keydown") {
  23.  
  24. this.greet("press");
  25.  
  26. } else if (e.type == "keyup") {
  27.  
  28. this.greet("release");
  29.  
  30. };
  31. };
  32.  
  33. };
  34.  
  35.  
  36. var fine = new Polite();
  37.  
  38. document.addEventListener("keydown", fine.route);
  39. document.addEventListener("keyup", fine.route);
  40.  
  41. console.log("To start, please press a button.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement