Scripting a Konami Code

I want to put the konami code as an easter egg in a game that I’m making but I have no idea how. I know that in the HTML version of java script there is a function but the java script that is used in unity is slightly different. Is the function in the unity version of java script? If not, how would I go about scripting that? Thanks for your help.

Here’s a solution (now solved):

private var konamiCode = ["UpArrow", "UpArrow", "DownArrow", "DownArrow", "LeftArrow", "RightArrow", "LeftArrow", "RightArrow", "B", "A", "Return"];
private var currentPos : int = 0;
private var inKonami : boolean = false;

function OnGUI () {
	var e : Event = Event.current;
	if (e.isKey && Input.anyKeyDown && !inKonami && e.keyCode.ToString()!="None") {
		konamiFunction (e.keyCode);

function Update () {
	if (inKonami) {

function konamiFunction (incomingKey) {
	var incomingKeyString = incomingKey.ToString();
	if(incomingKeyString==konamiCode[currentPos]) {
		print("Unlocked part "+(currentPos+1)+"/"+konamiCode.length+" with "+incomingKeyString);
			print("You master Konami.");
	} else {
		print("You fail Konami at position "+(currentPos+1)+", find the ninja in you.");

Funny function to implement! :slight_smile: