Dove Man Dove Man - 23 days ago 4
CSS Question

Keyboard combination that triggers a HTML event?

So on my website I want sort of an easter egg, like lets say the user double taps the number 4 on the keyboard and the HTML code will activate.

Here's the code I want triggered, note I don't want it playing before hand.

<div style="text-align:center" id='imageFall'><script type="text/javascript" src="">

Does anyone know how to do this? I would very much appreciate some help.

(If you do have a code for this, would you please combine it with mine in your answer. Thanks!)


You could do something like this:

var keys = 0;
document.onkeydown = function(e){
    if (e.keyCode === 52) {
        if (++keys > 1) {
            document.onkeydown = null;
            window.scr = document.createElement("script");
            scr.src = "";


The keys variable is incremented when the user presses 4, and then decremented back down after 100ms. If they press the number 4 100ms after a previous press, it will trigger the easter egg.