const { ipcRenderer } = require('electron');

const winType = 'tdWindow';

document.addEventListener('keydown', (e) => {
  const oEvent = e || window.oEvent;
  const bCtrlKey = oEvent.ctrlKey;
  const bShiftKey = oEvent.shiftKey;
  const code = e.which || e.keyCode;
  const bDeleteKey = code === 46; // delete
  const bDKey = code === 68;// d
  const bF5Key = code === 116;
  if (bF5Key) {
    ipcRenderer.send('refreshWindow', winType);
  }
  if (bCtrlKey && bShiftKey && bDKey) {
    ipcRenderer.send('openDevTools', winType);
  }
  if (bCtrlKey && bShiftKey && bDeleteKey) {
    ipcRenderer.send('openClearBox', winType);
  }
}, false);

window.ipcRenderer = ipcRenderer;
