jquery を使用できる場合は、pkarl からこのソリューションを試すことができます。
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
</script>
<script type="text/javascript">
$(function() {
// We check for a text selection when someone right-clicks
$(document).bind('contextmenu', checkSelection);
// We also check for a text selection if ctrl/command are pressed along w/certain keys
$(document).keydown(function(ev) {
// capture the event for a variety of browsers
ev = ev || window.event;
// catpure the keyCode for a variety of browsers
kc = ev.keyCode || ev.which;
// check to see that either ctrl or command are being pressed along w/any other keys
if((ev.ctrlKey || ev.metaKey) && kc) {
// these are the naughty keys in question. 'x', 'c', and 'c'
// (some browsers return a key code, some return an ASCII value)
if(kc == 99 || kc == 67 || kc == 88) {
return checkSelection()
}
}
});
})
// check to see if anything is currently highlighted by the visitor. If so, return false.
function checkSelection() {
if (window.getSelection) { var userSelection = window.getSelection(); }
else if (document.selection) { var userSelection = document.selection.createRange(); }
if(userSelection != '') return false;
}