Skip to content

Commit

Permalink
support zoom in/out with shifted or unshifted keys +,-,=,_
Browse files Browse the repository at this point in the history
also add new Firefox-specific keycodes to `d3.keybinding.js`
closes #2389
  • Loading branch information
bhousel committed Oct 12, 2014
1 parent 96fa48f commit 5782761
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 9 additions & 4 deletions js/id/ui/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ iD.ui.Zoom = function(context) {
.attr('class', function(d) { return d.id + ' icon'; });

var keybinding = d3.keybinding('zoom')
.on('+', function() { context.zoomIn(); })
.on('-', function() { context.zoomOut(); })
.on('⇧=', function() { context.zoomIn(); })
.on('dash', function() { context.zoomOut(); });

_.each(['=','ffequals','plus','ffplus'], function(key) {
keybinding.on(key, function() { context.zoomIn(); });
keybinding.on('⇧' + key, function() { context.zoomIn(); });
});
_.each(['-','ffminus','_','dash'], function(key) {
keybinding.on(key, function() { context.zoomOut(); });
keybinding.on('⇧' + key, function() { context.zoomOut(); });
});

d3.select(document)
.call(keybinding);
Expand Down
8 changes: 7 additions & 1 deletion js/lib/d3.keybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,20 @@ d3.keybinding = function(namespace) {
// Up Arrow Key, or ↓
'↓': 40, down: 40, 'arrow-down': 40,
// odities, printing characters that come out wrong:
// Firefox Equals
'ffequals': 61,
// Num-Multiply, or *
'*': 106, star: 106, asterisk: 106, multiply: 106,
// Num-Plus or +
'+': 107, 'plus': 107,
// Num-Subtract, or -
'-': 109, subtract: 109,
// Firefox Minus
'ffplus': 171,
// Firefox Minus
'ffminus': 173,
// Semicolon
';': 186, semicolon:186,
';': 186, semicolon: 186,
// = or equals
'=': 187, 'equals': 187,
// Comma, or ,
Expand Down

0 comments on commit 5782761

Please sign in to comment.