Skip to content
easy easter eggs (konami code, etc) for .NET
C# Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.nuget
Cheet.Core.Tests
Cheet.Core
Cheet.Wpf.Demo
Cheet.Wpf.Tests
Cheet.Wpf
nuget-pack
.gitignore
Cheet.CodeMaid.settings
Cheet.sln
Cheet.sln.DotSettings
Cheet.v2.ncrunchsolution
LICENSE.md
NuGetPack.bat
README.md
icon.png

README.md

Cheet.NET

easy easter eggs in .NET

Build status

This is a .NET port of the excellent cheet.js by Louis Acresti (namuol). I would recommend checking out that project if you need easter egg functionality in browser!

// Initialization
var cheet = new Cheet();
myUIElement.PreviewKeyDown += cheet.OnKeyDown;
cheet.Map("↑ ↑ ↓ ↓ ← → ← → b a", () => { Debug.WriteLine("Voilà!"); } );
cheet.Map("i d d q d", () => {
  Debug.WriteLine("god mode enabled");
});
cheet.Map("o n e a t a t i m e", new CheetCallbacks {
  Next = (str, key, num, seq) => {
    Debug.WriteLine("key pressed: " + key);
    Debug.WriteLine("progress: " + (double)num / seq.Length);
    Debug.WriteLine("seq: " + String.Join(" ", seq));
  },

  Fail = (str, seq) => {
    Debug.WriteLine("sequence failed");
  },

  Done = (str, seq) => {
    Debug.WriteLine("+30 lives ;)");
  }
});
cheet.Map("o n c e", () => {
  Debug.WriteLine("This will only fire once.");
  cheet.Disable("o n c e");
});
dynamic sequences = new {
  Cross = "up down left right",
  Circle = "left up right down"
};

cheet.Map(sequences.Cross);
cheet.Map(sequences.Circle);

cheet.Done((str, seq) => {
  if (str == sequences.Cross) {
    Debug.WriteLine("cross!");
  } else if (str == sequences.Circle) {
    Debug.WriteLine("circle!");
  }
});

Demo

The Cheet.Wpf.Demo project in this repository demos all of the above sequences.

Install

NuGet

Core project:

Install-Package Cheet.Core

WPF version:

Install-Package Cheet.Wpf

API

cheet.Map(sequence, done | callbacks { done, next, fail })

Map a sequence of keypresses to a callback. This can be called multiple times.

sequence (String)

A string representation of a sequence of key names.

Each keyname must be separated by a single space.

done(str, seq) (callback)

A callback to execute each time the sequence is correctly pressed.

Arguments:

  • str - The string representation of the sequence that completed.
  • seq - An array of keys representing the sequence that completed.

fail(str, seq) (callback)

A callback to execute each time a sequence's progress is broken.

Arguments:

  • str - The string representation of the sequence that failed.
  • seq - An array of keys representing the sequence that was pressed.

next(str, key, num, seq) (callback)

A callback to execute each time a correct key in the sequence is pressed in order.

Arguments:

  • str - The string representation of the sequence that is in progress.
  • key - The name of the key that was just pressed.
  • num - A number representing the current progress of the sequence. (starts at 0)
  • seq - An array of keys representing the sequence that is in progress.

cheet.Done(callback)

Set a global callback that executes whenever any mapped sequence is completed successfully.

callback(str, seq) (callback)

A callback to execute each time any sequence is correctly pressed.

Arguments:

  • str - The string representation of the sequence that completed.
  • seq - An array of keys representing the sequence that completed.

cheet.Next(callback)

Set a global callback that executes whenever any mapped sequence progresses.

callback(str, key, num, seq) (callback)

A callback to execute each time a correct key in any sequence is pressed in order.

Arguments:

  • str - The string representation of the sequence that is in progress.
  • key - The name of the key that was just pressed.
  • num - A number representing the current progress of the sequence. (starts at 0)
  • seq - An array of keys representing the sequence that is in progress.

cheet.Fail(callback)

Set a global callback that executes whenever any in-progress sequence is broken.

callback(str, seq) (callback)

A callback to execute each time any sequence's progress is broken.

Arguments:

  • str - The string representation of the sequence that failed.
  • seq - An array of keys representing the sequence that was pressed.

cheet.Disable(sequence)

Disable a previously-mapped sequence.

sequence (String)

The same string you used to map the callback when using cheet.Map(seq, ...).

cheet.Reset(sequence)

Resets a sequence that may or may not be in progress.

This will not cause Fail callbacks to fire, but will effectively cancel the sequence.

sequence (String)

The same string you used to map the callback when using cheet.Map(seq, ...).

Available Key Names

NOTE: Key names are case-sensitive

Directionals

  • left | L |
  • up | U |
  • right | R |
  • down | D |

Alphanumeric

  • 0-9 (main number keys)
  • a-z

Misc

  • backspace
  • tab
  • enter | return
  • shift |
  • control | ctrl |
  • alt | option |
  • command |
  • pause
  • capslock
  • esc
  • space
  • pageup
  • pagedown
  • end
  • home
  • insert
  • delete
  • equal | =
  • comma | ,
  • minus | -
  • period | .

Keypad

  • kp_0-kp_9
  • kp_multiply
  • kp_plus
  • kp_minus
  • kp_decimal
  • kp_divide

Function keys

  • f1-f12

License

MIT

Acknowledgements

This whole project was inspired and based on cheet.js by Louis Acresti (namuol). The API and all of this documentation is lifted from that project!

You can’t perform that action at this time.