From 5782761e48b81c31a577e9e8f382571269e29e44 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 12 Oct 2014 00:43:39 -0400 Subject: [PATCH] support zoom in/out with shifted or unshifted keys +,-,=,_ also add new Firefox-specific keycodes to `d3.keybinding.js` closes #2389 --- js/id/ui/zoom.js | 13 +++++++++---- js/lib/d3.keybinding.js | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/js/id/ui/zoom.js b/js/id/ui/zoom.js index 32aa92e6d8..1889a6b306 100644 --- a/js/id/ui/zoom.js +++ b/js/id/ui/zoom.js @@ -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); diff --git a/js/lib/d3.keybinding.js b/js/lib/d3.keybinding.js index 6aa39fb394..6e3fd1a817 100644 --- a/js/lib/d3.keybinding.js +++ b/js/lib/d3.keybinding.js @@ -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 ,