hackCode.js 890 B

12345678910111213141516171819202122232425262728293031323334
  1. (() =>
  2. {
  3. // 触发功能快捷鍵
  4. const EVENT_KEY = 'q'
  5. const inputType = {"text":1,"password":1,"number":1,"date":1,"color":1,"range":1,"month":1,"week":1,"time":1,"email":1,"search":1,"url":1,"textarea":1}
  6. // 不是输入状态时
  7. function inputTypeChk(e){
  8. if (e.path[0] ){
  9. let type = e.path[0].type ;
  10. if ( inputType[type]){
  11. return true
  12. }
  13. }
  14. }
  15. // 键盘监听
  16. document.body.addEventListener("keydown", (e) =>
  17. {
  18. let notDoubleKey = !e.ctrlKey && !e.metaKey && !e.altKey;
  19. if(e.key.toLocaleLowerCase() == EVENT_KEY && !inputTypeChk(e) && notDoubleKey)
  20. {
  21. if(e.shiftKey){
  22. Editor.Scene.callSceneScript('simple-handle-node', 'set-active-radio', {});
  23. }else{
  24. Editor.Scene.callSceneScript('simple-handle-node', 'set-active', {});
  25. }
  26. e.preventDefault();// 吞噬捕获事件
  27. return true
  28. }
  29. }, false);
  30. })();