Skip to content

Commit

Permalink
Updated index.html to stop keys from sticking (for nerds)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuho committed Feb 7, 2012
1 parent f58023b commit dc44f9a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ <h1 id="text" style="font-size:8em;font-weight:100; text-top; position:absolute;
document.title = document.URL.match(/[^/?$:]{5,}/);
document.getElementById('text').textContent = document.title;
document.body.style.color='#'+((Math.random()*0xAAAAAA+0x555554)<<0).toString(16);
window.onkeydown = function(event){toggleKey(event);};
window.onkeyup = function(event){toggleKey(event);};
window.onkeydown = function(event){setOn(getKey(event));};
window.onkeyup = function(event){setOff(getKey(event));};
window.onfocus = function(event){setOff('CTRL');setOff('SHIFT');};
window.onblur = function(event){setOff('CTRL');setOff('SHIFT');};
document.getElementById('PI').onmousedown = function(){clickPi();};
document.scripts[0].parentNode.removeChild(document.scripts[0]);
}
var toggleKey = function(e){
if(e.keyCode === 17 ) toggleOn("CTRL");
if(e.keyCode === 16 ) toggleOn("SHIFT");
var getKey = function(e){
if(e.keyCode === 17 ) return 'CTRL';
if(e.keyCode === 16 ) return 'SHIFT';
}
var setOff = function(id){
if(id){
document.getElementById(id).style.display = "none";
window[id] = false;
}
}
var setOn = function(id){
document.getElementById(id).style.display = "inline-block";
window[id] = true;
}
var toggleOn = function(id){
if(document.getElementById(id).style.display === "none"){
Expand All @@ -32,12 +44,6 @@ <h1 id="text" style="font-size:8em;font-weight:100; text-top; position:absolute;
document.getElementById(id).style.display = "none";
window[id] = false;
};
if(CTRL && SHIFT){
document.getElementById('PI').style.cursor="crosshair";
}
else{
document.getElementById('PI').style.cursor="default";
};
}
var clickPi = function(){
if(true ===CTRL && true === SHIFT){
Expand Down

0 comments on commit dc44f9a

Please sign in to comment.