Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unbreak handling of Ctrl-RightArrow in the editor window #331

Merged
merged 1 commit into from

2 participants

@anchor

I use Ctrl+ArrowKeys heavily when editing text to jump word-by-word, and noticed that Radiant's editor breaks jump-forward functionality - nothing happens.

After digging around for a while I nailed it to the accesskey handler. It will attempt to find accesskeys anywhere on the page, even nonsensical ones. While not a perfect solution, this fixes my immediate issue.

I think a proper solution would require sanity-checking the incoming keyCode values, as noted in the patch.

@saturnflyer saturnflyer merged commit c21d7df into radiant:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 11, 2012
  1. Unbreak handling of Ctrl-RightArrow in the editor window

    Anchor Systems authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 public/javascripts/admin/shortcuts.js
View
8 public/javascripts/admin/shortcuts.js
@@ -3,8 +3,14 @@ var ShortcutKeysBehavior = Behavior.create({
var character = String.fromCharCode(event.keyCode);
if(!event.shiftKey && !character.blank())
character = character.toLowerCase();
+ // Blindly passing RIGHT_ARROW through fromCharCode() returns a single-quote character (ascii decimal 39).
+ // I suspect that causes a bad string interpolation when evaluating `button`.
+ // Adding double-quotes to the accesskey spec seems to fix it.
+ // Now of course now keyCode 34 (double-quote in ascii decimal) will cause a problem... but your browser will likely catch Ctrl+PgDn anyway
+ // We should only evaluate keyCodes that can come from printable characters, now sure how feasible that is.
+ // Eg. http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
if(event.ctrlKey && event.keyCode != 17){
- var button = $$('input[accesskey='+character+']')[0];
+ var button = $$('input[accesskey="'+character+'"]')[0];
if(button){
event.stop();
button.click();
Something went wrong with that request. Please try again.