diff --git a/src/jqconsole.coffee b/src/jqconsole.coffee index 5621b3b..98f1f35 100644 --- a/src/jqconsole.coffee +++ b/src/jqconsole.coffee @@ -771,7 +771,7 @@ class JQConsole # We let the browser take over during output mode. # Skip everything when a modifier key other than shift is held. # Allow alt key to pass through for unicode & multibyte characters. - if @state == STATE_OUTPUT or event.metaKey or event.ctrlKey + if @state == STATE_OUTPUT or event.metaKey or (event.ctrlKey and !event.altKey) return true # IE & Chrome capture non-control characters and Enter. diff --git a/test/setup.coffee b/test/setup.coffee index 1a28c62..efdb2c5 100644 --- a/test/setup.coffee +++ b/test/setup.coffee @@ -13,9 +13,10 @@ window.jqconsoleSetup = -> $container.appendTo('body') jqconsole = new JQConsole($container, 'header', 'prompt_label', 'prompt_continue') typer = - typeA: -> + typeA: (options = {}) -> e = $.Event('keypress') e.which = 'a'.charCodeAt(0) + e[k] = v for k, v of options jqconsole.$input_source.trigger e keyDown: (code, options = {}) -> diff --git a/test/shortcuts-test.coffee b/test/shortcuts-test.coffee index 647f7ae..6bf64a5 100644 --- a/test/shortcuts-test.coffee +++ b/test/shortcuts-test.coffee @@ -1,4 +1,4 @@ -{jqconsole, typer: {keyDown}} = jqconsoleSetup() +{jqconsole, typer: {typeA, keyDown}} = jqconsoleSetup() describe 'Shortcuts', -> describe '#RegisterShortcut', -> @@ -58,3 +58,14 @@ describe 'Shortcuts', -> counter++ keyDown 'a'.charCodeAt(0), metaKey: on ok counter + + it 'altgr inputs character instead of invoking shortcut', -> + jqconsole.Prompt true, -> + counter = 0 + jqconsole.RegisterShortcut 'a', -> + strictEqual this, jqconsole + counter++ + keyDown 'a'.charCodeAt(0), ctrlKey: on, altKey: on + typeA(altKey: on, ctrlKey: on) + equal counter, 0 + equal jqconsole.$prompt.text().trim(), 'prompt_labela'