homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

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)

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)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved