Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7172179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:33:49+00:00 2026-05-28T15:33:49+00:00

taken from: https://github.com/keithamus/jwerty Does anyone know how to unbind after setting up a .key

  • 0

taken from: https://github.com/keithamus/jwerty

Does anyone know how to unbind after setting up a .key binding?

As a test, I want this set globally when something is selected

jwerty.key('↑', function(e) {
e.preventDefault();
alert('up');
});

then unbound when that object is unselected. That stuff is already set up, inside that unselect statement though I want to call the jwerty unbind but can’t figure out how.

but when I a) don’t know how to unbind it explicitly or b) if I try to change it to a different anonymous function I still see the alert.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:33:50+00:00Added an answer on May 28, 2026 at 3:33 pm

    If you want a global key handler that can be removed, you have to bind it using jQuery http://jsfiddle.net/mendesjuan/LxQ4H/2/

    function doit() {
      alert('up');
    }
    // to bind use namespaces so it can be unbound without removing
    $(document.body).bind('keydown.test', jwerty.event('↑', doit));
    
    // a button that unbinds the key handler
    $('#btn').click(function(){
        $(document.body).unbind('keydown.test')
    });
    

    If you want the key handler to be scoped to an HTML element, you need to set the listener on the element, not globally. This will only fire if the element that it’s bound to has focus. Just pass in a selector to bind a shortcut local to that element http://jsfiddle.net/mendesjuan/LxQ4H/

    jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }, this, '#myinput');
    

    If your element doesn’t take focus by default (a div), you need to make it focusable by doing the following. http://jsfiddle.net/mendesjuan/LxQ4H/1/

    // or 0, 1,2 3 if you want it to be tabbable
    document.getElementById('#mydiv').tabIndex = -1; 
    

    These code samples came from https://github.com/keithamus/jwerty (same link you already mentioned)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've taken a checkout of a project on github from below... https://github.com/wakaleo/game-of-life/ I can
Below example is taken from this documentation page: https://github.com/activescaffold/active_scaffold/wiki/Chaining-Form-Fields [Example start] You can set
So I downloaded a wrapper class from this github link: https://github.com/ignaciovazquez/Highrise-PHP-Api and I'm just
I have upload the video on facebook using following code Help From : https://github.com/zoul/facebook-ios-sdk/
I am using the jQuery tree from here https://github.com/pioz/jquery-tree#readme The problem is rendering of
UPDATE 9th june 2012: Setup with mongoid 3.0.0.rc at heroku, see this gist: https://gist.github.com/2900804
I'm trying delayed_job now, and have some questions. From the http://github.com/collectiveidea/delayed_job page, I can
Help! How to change Bullet Charts JavaScript code from these web-page: http://mbostock.github.com/d3/ex/bullet.html in such
I am developing a Rails app using OmniAuth, OmniAuth-salesforce and this gem: https://github.com/heroku/databasedotcom I
I recently forked https://github.com/fortuity/rails3-mongoid-omniauth and tried to get login working for different providers. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.