Skip to content

Instantly share code, notes, and snippets.

@ahollenbach
Created December 30, 2013 22:01
Show Gist options
  • Select an option

  • Save ahollenbach/8188989 to your computer and use it in GitHub Desktop.

Select an option

Save ahollenbach/8188989 to your computer and use it in GitHub Desktop.

Revisions

  1. ahollenbach created this gist Dec 30, 2013.
    25 changes: 25 additions & 0 deletions KeyboardShortcuts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // Noteflight (http://www.noteflight.com/), a music annotation software for the web,
    // has an awesome new HTML5 editor that they are working on. Unfortunately, it doesn't
    // support ctrl+c and ctrl+v operations for some reason, (at least on my Windows/Chrome
    // configuration), so I wrote a short script to fix that.

    var cpy=$(".headerMenuItem:contains('Copy')").first(),
    pst=$(".headerMenuItem:contains('Paste')").first();

    var CTRL_KEY = 17,
    V_KEY = 86,
    C_KEY = 67;

    var ctrl = false;

    $(document).keydown(function(e) {
    if (e.keyCode == CTRL_KEY) ctrl = true;

    if (ctrl && e.keyCode == C_KEY) {
    cpy.click();
    } else if(ctrl && e.keyCode == V_KEY) {
    pst.click();
    }
    }).keyup(function(e) {
    if (e.keyCode == CTRL_KEY) ctrl = false;
    });