Skip to content

Instantly share code, notes, and snippets.

@songfei1983
Last active August 29, 2015 14:10
Show Gist options
  • Save songfei1983/ff11bd3954366a2c5bb1 to your computer and use it in GitHub Desktop.
Save songfei1983/ff11bd3954366a2c5bb1 to your computer and use it in GitHub Desktop.
よくWebOSやJSで禁止されるキー設定 ref: http://qiita.com/songfei1983/items/f8d5fde5709c74c6b5f5
var event = e || window.event;
var k = event.keyCode;
if((event.ctrlKey == true && k == 82) || (event.ctrlKey == true && k == 78) || (k == 116) || (event.ctrlKey == true && k == 116))
{
event.keyCode = 0;
event.returnValue = false;
event.cancelBubble = true;
return false;
}
document.oncontextmenu = function(){
return false;
};
document.ondragstart = function(){
return false;
};
document.onselectstart = function( e ){
var event = e || window.event;
var tagName = '';
try{
tagName = (event.target || event.srcElement).tagName.toLowerCase();
}
catch(e){}
if( tagName != 'textarea' && tagName != 'input'){
return false;
}
}
document.onclick = function( e ){
//Shift + click 及び Ctrl + click を禁止
var event = e || window.event;
var tagName = '';
try{
tagName = (event.target || event.srcElement).tagName.toLowerCase();
}
catch(e){}
if( (event.shiftKey || event.ctrlKey) && tagName == 'a' ){
event.keyCode = 0;
event.returnValue = false;
event.cancelBubble = true;
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment