Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Initiate CHEAT CODES</h1>
<small class="warning">HINT: You may need to click on this area to give it focus to get going</small>
<p>Try typing "cheat"!</p>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Share+Tech+Mono);

body{
  font-size:20px;
  padding:1em;
  font-family:"Share Tech Mono", monospace;
  text-align:center;
  background:#112211 url('https://hosted.eightarms.co.uk/2013/11/21/monitor.png');
  color:#17f741;
  text-shadow:0 0 3px #6eff89;
}

.warning{
  position:fixed;
  bottom:10px;
  right:10px;
  width:20%;
  text-align:right;
}

.cheat{
  color:#d8ff00;
  text-shadow:0 0 6px #6eff89;
}
              
            
!

JS

              
                var cheats = [{
  code : "cheat", // the cheat code you have to type
  cheat : "Cheat mode activated. Wait... -it was always activated!", // the cheat (must change to be a function at some point)
  complete : 0 // keeps an eye out for how many of the letters have been typed
},{
  code : "abc",
  cheat : "BOOM!",
  complete : 0
},{
  code : "lewis", 
  cheat : "HEY MAN!", 
  complete : 0 
},{
  code : "impressive", 
  cheat : "Wicked code.", 
  complete : 0 
},{
  code : "tony", 
  cheat : "Hoootspa!", 
  complete : 0 
},];

document.onkeydown = function (e) {
  var keyPress;

  if (typeof event !== 'undefined') {
    keyPress = event.keyCode;
  }
  else if (e) {
    keyPress = e.which;
  }
  letter = String.fromCharCode(keyPress).toLowerCase();

  for(var i = 0; i < cheats.length; i ++){
    cheat_code = cheats[i].code;
    characters_complete = cheats[i].complete;
    if(cheat_code.charAt(characters_complete) == letter){
      cheats[i].complete ++;
      if(cheats[i].complete == cheats[i].code.length){
        show_cheat(cheats[i].cheat);
        cheats[i].complete = 0;
      }
    }
    else{
      cheats[i].complete = 0;
    }
  }
  return false;
};

function show_cheat(text){
  $("body").append("<h1 class='cheat'>" + text + "</h1>").find(".cheat").delay(2000).fadeOut("slow");
}
              
            
!
999px

Console