Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add removeHotkey to keyboard module, closes #110 #453

Merged
merged 2 commits into from
Aug 17, 2015

Conversation

thomsbg
Copy link
Contributor

@thomsbg thomsbg commented Aug 13, 2015

Takes a string, number, or hotkey object, returns the handler function.

Takes a string, number, or hotkey object.
@@ -30,6 +30,13 @@ class Keyboard
@hotkeys[which].push(hotkey)
)

removeHotkey: (hotkey) ->
hotkey = if Keyboard.hotkeys[hotkey] then Keyboard.hotkeys[hotkey] else hotkey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we toUpperCase() a string to support case insensitive removals ex. removeHotkey('bold'); Many users might not and need not know the hotkeys object has its keys in all caps.

@jhchen
Copy link
Member

jhchen commented Aug 13, 2015

We had discussed that the handler for a hotkey be returned by the removeHotkey function but there may be more than one. Should it just remove and return the first or remove and return all of them? The latter of removing all of them makes more intuitive sense but returning a different type (an array) is not.

@thomsbg
Copy link
Contributor Author

thomsbg commented Aug 14, 2015

@jhchen I've added another commit which addresses your concerns (and actually makes it work!)

I decided to rename the method to removeKeys (plural) to indicate than the return value is an array.

I also added the ability to specify which handler you wanted removed, along the lines of jQuery's off(event, handler).

@jhchen
Copy link
Member

jhchen commented Aug 17, 2015

Thanks for the changes!

jhchen added a commit that referenced this pull request Aug 17, 2015
Add removeHotkeys to keyboard module, closes #110
@jhchen jhchen merged commit 10544f7 into slab:develop Aug 17, 2015
@thomsbg thomsbg deleted the remove-hotkey branch October 7, 2015 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants