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.
Adding the standard keyboard ctrl+c/v shortcuts to Noteflight
// 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;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment