Add ⌘ Cmd key as alternative to Ctrl key to make Mac users happy.

This commit is contained in:
Dave C-J 2014-10-27 15:07:34 +00:00
parent bbaf7bf247
commit c51866c2c5
2 changed files with 6 additions and 3 deletions

View File

@ -136,6 +136,9 @@
<td><span class="help-key">Ctrl</span> <span class="help-key">+</span></td><td>Zoom in</td>
<td><span class="help-key">Ctrl</span> <span class="help-key">-</span></td><td>Zoom out</td>
</tr>
<tr>
<td colspan="4">Mac users can use the <b>⌘ - Cmd</b> key rather than Ctrl key.</td>
</tr>
</table>
</div>
<div class="modal-footer">

View File

@ -24,19 +24,20 @@ RED.keyboard = (function() {
if (handler && handler.ondown) {
if (!handler.modifiers ||
((!handler.modifiers.shift || d3.event.shiftKey) &&
(!handler.modifiers.ctrl || d3.event.ctrlKey ) &&
(!handler.modifiers.ctrl || !handler.modifiers.meta || d3.event.ctrlKey || d3.event.metaKey) &&
(!handler.modifiers.alt || d3.event.altKey ) )) {
handler.ondown();
}
}
});
d3.select(window).on("keyup",function() {
if (!active) { return; }
var handler = handlers[d3.event.keyCode];
if (handler && handler.onup) {
if (!handler.modifiers ||
((!handler.modifiers.shift || d3.event.shiftKey) &&
(!handler.modifiers.ctrl || d3.event.ctrlKey ) &&
(!handler.modifiers.ctrl || !handler.modifiers.meta || d3.event.ctrlKey || d3.event.metaKey) &&
(!handler.modifiers.alt || d3.event.altKey ) )) {
handler.onup();
}
@ -46,7 +47,6 @@ RED.keyboard = (function() {
var mod = modifiers;
var cbdown = ondown;
var cbup = onup;
if (typeof modifiers == "function") {
mod = {};
cbdown = modifiers;