The problem seems to be that Chrome does not generate a keypress event when the control key is depressed. The logic in paperjs depends on the keypress event to (ultimately) generate the keyup event.
It's a bit confusing but you can take a look at paper's Key.js starting on the line that begins DomEvent.add(document, {
. You can see that handleKey
is only called for a non-special key on the keypress
event. handleKey
is the code that inserts the key code into charCodeMap
. So when the keyup
event occurs paper doesn't find code
in charCodeMap
and doesn't call handleKey
.
How to get around this?
What you're doing is straightforward, so maybe just using the native DOM event handling will take care of it:
document.onkeyup = function (e) {
var code = e.which || e.keyCode;
if (code === 'v' && e.ctrlKey) {
// do your pasting here
}
}
You may need to account for other browser variations, but this should get you started. If you're using jQuery you should consider using jQuery's keyup function. That handles cross browser issues transparently.