8000 Feature Request: unbind scope · Issue #166 · madrobby/keymaster · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Feature Request: unbind scope #166
Open
@caillou

Description

@caillou

Feature Request: Unbind Scope

Motivaiton

I often find myself writing the following code:

['up', 'down', 'esc'].forEach((key) => {
  keymaster.unbind(this.scope, key)
})

While this works, it could potentially lead to memory leaks, if a specific key is forgotten. E.g. if my module would have registered key('space', this.scope, cb).

Proposed Solution

A possibility to remove every event-handler for a given scope would be very helpful. Possible APIs:

keymaster.unbind(null, this.scope)
keymaster.unbindScope(this.scope)

Discussion

If such a feature is desired, I would be willing to send a PR along with tests. This being said, I would love to get your input on this beforehand. Do you consider the use-case good enough to add this functionality to keymaster? And if yes, what would the ideal API for this be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0