/*
* @title F12は使わせて!!
* @description [F12]ほか制限されている幾つかのキー操作を可能に
* @include http://*
* @include https://*
* @license MIT License
* @require
* @javascript_url
*/
( () => {
const
allowd_keycode_map = {
122 : { // F11
combinations : []
},
123 : { // F12
combinations : []
},
68 : { // D
combinations : [ 'altKey', ]
},
69 : { // E
combinations : [ 'ctrlKey', ]
},
76 : { // L
combinations : [ 'ctrlKey', 'metaKey', ]
},
},
on_key_event = ( event ) => {
if ( ( event.isComposing ) || ( event.keyCode == 229 ) ) {
// IME入力中は無視
return;
}
let allowd_key_info = allowd_keycode_map[ event.keyCode ];
if ( ! allowd_key_info ) {
return;
}
let combinations = allowd_key_info.combinations || [];
if ( 0 < combinations.length ) {
let match_number = combinations.filter( key_names => {
if ( typeof key_names == 'string' ) {
key_names = [ key_names ];
}
return key_names.length == key_names.filter( key_name => event[ key_name ] ).length;
} ).length;
if ( match_number < 1 ) {
return;
}
}
event.stopPropagation();
};
document.addEventListener( 'keydown', on_key_event, true );
document.addEventListener( 'keyup', on_key_event, true );
} )();