Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Not sure how to capture type without a form




6:43 am on May 2, 2013 (gmt 0)

I would like to embed an easter egg in my page where it activated by someone typing in "up, up, down, down, left, right, left, right, B, A, enter" while they are on the page. I do not want a form on the page. is this even possible in php?

Many thanks



7:09 am on May 2, 2013 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

php is a server side technology, it cannot capture anything the user does.
i'm not a javascript guru but i imagine that is what you want to do what you desire.


8:04 pm on May 2, 2013 (gmt 0)

awesome I will look into that.



9:11 pm on May 7, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

As topr8 said, not the right forum, but...

Using the jQuery plugin ([jquery.com ]), this will do what you want to do. Just replace that alert with your easter egg code:

(function($) {
var sequence = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13];
var currentSequence = [];
$(document).ready(function() {
$(window).on('keydown', function(event) {
if(sequence[currentSequence.length] != event.which) {
currentSequence = [];
if(sequence.length == currentSequence.length) {
currentSequence = [];
alert('THA KONAMI CODE!');

I suggest using the jQuery plugin (Or a similar tool) for this sort of thing, as the keyboard "key codes" can vary between browsers, and jQuery normalizes them for you through .which

Featured Threads

Hot Threads This Week

Hot Threads This Month