Skip to content

Commit

Permalink
Added notes and solution for Project 12 - KONAMI code
Browse files Browse the repository at this point in the history
  • Loading branch information
lisaychuang committed Apr 30, 2018
1 parent daf627c commit 8154707
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
35 changes: 29 additions & 6 deletions 12 - Key Sequence Detection/index-projectnotes.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Key Detection</title>
<script type="text/javascript" src="http://www.cornify.com/js/cornify.js"></script>
<meta charset="UTF-8">
<title>Key Detection</title>
<script type="text/javascript" src="http://www.cornify.com/js/cornify.js"></script>
</head>

<body>
<script>
</script>
<script>

const pressed = [];
const secretCode = 'cooljs';

function keyLog(e) {
pressed.push(e.key);
pressed.splice(-secretCode.length -1, pressed.length - secretCode.length)
console.log(pressed);

// if user enters the secretCode, give them some 🦄 unicorn love!
if (pressed.join('').includes(secretCode)) {
console.clear();
console.warn('DING DING DING!!! You found the secret code!')
cornify_add();
}
}

// Add event listener to track keys pressed
window.addEventListener('keyup', keyLog)

</script>
</body>
</html>

</html>
17 changes: 16 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,19 @@ The HTML Video element `<video>` embeds a media player which supports video play

### [Node.textConten](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)

`Node.textContent` property represents the text content of a node and its descendants, and can be used to `get` or `set` the text content.
`Node.textContent` property represents the text content of a node and its descendants, and can be used to `get` or `set` the text content.

## Project 12: KONAMI CODE

Konami code was originally a cheat code that appears in many Konami video games - a sequence of buttons on the game controller that enable a cheat or other effects. The code is also present as an Easter egg on a number of websites.

### [KeyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)

The KeyboardEvent.key read-only property returns the value of a key or keys pressed by the user. Its value is determined as follows:

See a [full list of key values here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)

### [CornifyJS](http://www.cornify.com/)

A JS library that randomly populars unicorn and rainbos on your webpage!

0 comments on commit 8154707

Please sign in to comment.