Giter Site home page Giter Site logo

Comments (3)

ProLoser avatar ProLoser commented on September 15, 2024

Try putting it on the <body> tag.

from ui-utils.

clakech avatar clakech commented on September 15, 2024

Hi,

Thanks for your answer.

I can't do this because I don't wan't those shortcuts to be activated on every view of my app, only in a specific view, so I would like the directive to be inside this specific view, on a div for instance or any other tag on this view.

Since I didn't manage to use ui-keypress, I move to mousetrap.js

If I found a way to use ui-keypress for my need, I will use it because mousetrap.js is not angular 'ready', so I need to add a few $scope.$apply() in my code and I prefer to avoid this.

Regards,

from ui-utils.

yaru22 avatar yaru22 commented on September 15, 2024

@clakech You can use ui-keypress on div element by having tabindex="0" attribute on that div. Checkout http://stackoverflow.com/questions/148361/how-can-i-give-keyboard-focus-to-a-div-and-attach-keyboard-event-handlers-to-it and http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-TECHS/SCR29.html for more information on tabindex.

e.g.

<div style="outline: 0; border: 1px solid red;" tabindex="0" ui-keypress="{13:'keypressCallback($event)'}">
  Click inside this div and hit [Enter]. You can make any element accept keyboard event by adding tabindex="0" attribute to the element.
</div>

I'll create a PR with this updated example.

from ui-utils.

Related Issues (20)

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.