Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Polite() {
- this.press = "Such pressing";
- this.release = "and what a nice release!"
- this.greet = function(d) {
- if (d == "press") {
- console.log(this.press);
- } else if (d == "release") {
- console.log(this.release);
- };
- };
- this.route = function(e) {
- if (e.type == "keydown") {
- this.greet("press");
- } else if (e.type == "keyup") {
- this.greet("release");
- };
- };
- };
- var fine = new Polite();
- document.addEventListener("keydown", fine.route);
- document.addEventListener("keyup", fine.route);
- console.log("To start, please press a button.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement