2015-01-29 10 views
0

NodeJ.js와 Angular.js를 사용하여 AppJs 앱을 만들었지 만 키보드 바로 가기를 만들 수는 없습니다.AppJs 키보드 단축키 (복사, 붙여 넣기, 클립 보드, 종료, 모두 선택 ...)

나는 메뉴 바의 작업이 있지만 "&"트릭 내 Mac에서 작동하지 않습니다

내가 할 노력하고있어 다른 것은 복사/붙여 넣기를 허용하고 모든 사용을 선택하는 것입니다
var menubar = appjs.createMenu([{ 
    label:'&File', 
    submenu:[{ 
     label:'&Quit', 
     action: function(){ 
      window.close(); 
     } 
     }] 
    }, 
    { 
     label:'&Window', 
     submenu:[ 
     { 
      label:'&Fullscreen', 
      action:function(item) { 
      window.frame.fullscreen(); 
      console.log(item.label+" called."); 
      } 
     }, 
     { 
      label:'&Minimize', 
      action:function(){ 
      window.frame.minimize(); 
      } 
     }, 
     { 
      label:'Maximize', 
      action:function(){ 
      window.frame.maximize(); 
      } 
     }, 
     { 
      label:''//separator 
     }, 
     { 
      label:'Restore', 
      action:function(){ 
      window.frame.restore(); 
      } 
     } 
     ] 
    } 
    ]); 

CMD + C, CMD + V 및 CMD + A ...하지만 그 방법을 찾을 수 없습니다 ...

"준비"이벤트 (서버 측)에이 코드가 있습니다. 마녀가 키보드 이벤트를 캡처하지만 나는 그들과 무엇을 해야할지 모르겠다. (

window.on('ready', function(){ 
    window.require = require; 
    window.process = process; 
    window.module = module; 
    window.addEventListener('keydown', function(e){ 
    // SELECT ALL (CMD+A) 
    if (e.keyCode == 65) { 
     console.log('SELECT ALL'); 
    } 
    // COPY (CMD+C) 
    if (e.keyCode == 67) { 
     console.log('COPY'); 
    } 
    // PASTE (CMD+V) 
    if (e.keyCode == 86) { 
     console.log('PASTE'); 
    } 
    if (e.keyIdentifier === 'F12' || e.keyCode === 74 && e.metaKey && e.altKey) { 
     window.frame.openDevTools(); 
    } 
    }); 
}); 

이 주제에 불이 들어 오면, 매우 감사하겠습니다.

답변

0

"execCommand"을 사용하여 키보드 단축키를 작동시키는 방법을 발견했습니다. 은 "준비"이벤트에서

은, 그냥 다음과 같이 명령을 추가 :

window.on('ready', function(){ 
    window.require = require; 
    window.process = process; 
    window.module = module; 
    window.addEventListener('keydown', function(e){ 
    // console.log(e.keyCode); 
    // SELECT ALL (CMD+A) 
    if (e.keyCode == 65) { 
     window.document.execCommand('selectAll'); 
    } 
    // COPY (CMD+C) 
    if (e.keyCode == 67) { 
     window.document.execCommand('copy'); 
    } 
    // EXIT (CMD+M) 
    if (e.keyCode == 77) { 
     window.frame.minimize(); 
    } 
    // EXIT (CMD+Q or CMD+W) 
    if (e.keyCode == 81 || e.keyCode == 87) { 
     window.close(); 
    } 
    // PASTE (CMD+V) 
    if (e.keyCode == 86) { 
     window.document.execCommand('paste'); 
    } 
    // CUT (CMD+X) 
    if (e.keyCode == 88) { 
     window.document.execCommand('cut'); 
    } 
    if (e.keyIdentifier === 'F12' || e.keyCode === 74 && e.metaKey && e.altKey) { 
     window.frame.openDevTools(); 
    } 
    }); 
}); 

희망이 도움이 누군가!