Giter Site home page Giter Site logo

hold-event's Introduction

hold-event

Provides key hold-start, holding, hold-end and other events.

Key press and hold

The 1st argument is a KeyboardEvent.code.

const keyLeft = new holdEvent.KeyboardKeyHold( 'ArrowLeft' );

keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_START, ( event ) => console.log( event ) );
keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLDING, ( event ) => console.log( event ) );
keyLeft.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_END, ( event ) => console.log( event ) );

Element press and hold

const $button = document.getElementById( 'button' )
const buttonHold = new holdEvent.ElementHold( $button );

buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_START, ( event ) => console.log( event ) );
buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLDING, ( event ) => console.log( event ) );
buttonHold.addEventListener( holdEvent.HOLD_EVENT_TYPE.HOLD_END, ( event ) => console.log( event ) );

hold-event's People

Contributors

yomotsu avatar dependabot[bot] avatar eviltik avatar

Stargazers

horizon avatar Aglaia Feli avatar nolze avatar Dennis Smolek avatar Vincent Wang avatar Kyle L. McGregor avatar Vinzenz Aubry avatar Jeff Wang avatar OftenGuy avatar Felipe Holanda avatar Renan Victor avatar Serhii avatar  avatar Alan Jo avatar takashi-tk avatar Smarthug avatar Austin avatar

Watchers

 avatar James Cloos avatar  avatar

hold-event's Issues

keyCode is deprecated

KeyboardEvent.keyCode is deprecated now, could you please update it to code or key?
image

Can this be extended to TouchEvents?

Thank you for this also, it saved a lot of work for me in my Virtual Exhibition. This works perfectly with keyboard and movement icons. Can this be extended to touchevents?

I read about this a bit and I can see the problem. Even nipplejs lacks the "hold" support. Or do you know a working method/npn/git for this purpose?

add keyboard shift / control / alt key status when sending holding events

Hi @yomotsu

Thank you for your open work.

To handle walk/run in your great camera controls component, using hold event, we need extra keys (shift, alt, ctrl)

keyLeft.addEventListener( 'holding', event => {
    if (event.shiftKey) ...
    if (event.altKey) ...
    if (event.ctrlKey) ...
} );

Should i PR or perhaps you can do that quickly ?

thank you

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.