Git Product home page Git Product logo

ctrl's Introduction

A input manager for flash/haXe

So you don't have to write addEventListener to get keyboard input or mouse input

You don't have to remember the keycode, just pass the string...

It's used like this...
In your main game loop, add Ctrl.instance.update(); in the end of the loop...

For a shortcut you can store the singleton instance in a local variable for quick access...

var c = Ctrl.instance;

For checking whether a key is just pressed, use like this

c.isPressed(theKey);

For a key is down

c.isDown(theKey);

For a key is just released, use like this

c.isReleased(theKey);

For a key is up, use like this

c.isUp(theKey);


The "theKey" is a string, it can be "A", "B", "c", "1", "F1", "BacKSpace", "[", "up", etc...
It's case insensitive, so UpperCase or LowerCase is work well...

For mouse handling

c.mouseLeave : a bool variable, to check if the mouse is in the swf or not
c.mouseDown : a bool variable, to check if the mouse is down or not
c.mousePressed : a bool variable, to check if the mouse is just pressed or not
c.mouseUp : a bool variable, to check if the mouse is up or not
c.mouseReleased : a bool variable, to check if the mouse is just released or not

c.mouseX : a float variable, indicate mouse X position
c.mouseY : a float variable, indicate mouse Y position
c.mouseWheel : a int variable, indicate the mouse wheel delta

And you can get the lastPressed key and lastReleased key too...

And... support key buffering, so you can track user input for several input.

And... check capsLock or numLock thingy

and another feature...
get justPressed character, usefull for text field thingy...
c.getChar()
it will give you the just pressed char, it depends on whether you hold shift or capslock is on or off.

ctrl's People

Contributors

alijaya avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.