Giter VIP home page Giter VIP logo

ncadence's Introduction

NCadence

C# Library to allow a piece of code to be run whenever a timed sequence of keys is pressed

Example

When I hold down the left control key for around 2 seconds, let go, then press right shift twice within 1 second, then press right shift again after 5 seconds, run [your code here]

public class Example1
{
  public NCadence.Sequencer Sequencer { get; set; }
  public void Setup()
  {
    Sequencer = new NCadence.Sequencer();
    Sequencer.Add(new Cadence()
      .Tolerance(250)                     // Following actions must occur within 250 milliseconds of the listed values
      .PressAndHold(PKey.LControl, 2000)  // User must first hold down the left control key for between 1750-2250 milliseconds
      .KeyPress(PKey.RShift, 2, 1000)     // User must then press and release the right shift key twice between 750-1250 milliseconds
      .Pause(5000).Ish(1000)              // User must press no key of any type for between 4000-6000 milliseconds
      .KeyPress(PKey.RShift)              // User must then press and release the right shift key again within 250-500 milliseconds
      .Call(OnCommand)                    // When all that happens, call OnCommand()
      .MaxRuns(3);                        // But don't allow this to happen more than 3 times`1`1
  }

  public void StartSequencer()
  {
    Sequencer.Enable();
  }

  public void StopSequencer()
  {
    Sequencer.Disable();
  }

  public void OnCommand()
  {
    Console.WriteLine("ding!");
  }
}

ncadence's People

Contributors

willrawls avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.