handle keyboard shortcuts ending with '-'

This commit is contained in:
Paul Ivanov 2014-03-19 16:24:53 -07:00
parent 4cf1717980
commit 21ebaf2e32
2 changed files with 4 additions and 1 deletions

View File

@ -88,12 +88,14 @@ IPython.keyboard = (function (IPython) {
// 3. Sort '-' separated modifiers into the order alt-ctrl-meta-shift
// 4. Normalize keys
shortcut = shortcut.toLowerCase().replace('cmd', 'meta');
shortcut = shortcut.replace('--', '-'); // catch shortcuts using '-' key
var values = shortcut.split("-");
if (values.length === 1) {
return normalize_key(values[0]);
} else {
var modifiers = values.slice(0,-1);
var key = normalize_key(values[values.length-1]);
key = key || '-'; // '-' will make the key undefined, since we split on it
modifiers.sort();
return modifiers.join('-') + '-' + key;
}

View File

@ -71,8 +71,9 @@ var IPython = (function (IPython) {
return build_div('<h4>Command Mode (press <code>Esc</code> to enable)</h4>', command_shortcuts);
};
var special_case = { pageup: "PageUp", pagedown: "Page Down" };
var special_case = { pageup: "PageUp", pagedown: "Page Down", '': '-' };
var prettify = function (s) {
s = s.replace('--', '-'); // catch shortcuts using '-' key
var keys = s.split('-');
var k, i;
for (i in keys) {