JAVASCRIPT   36

action.js

Guest on 10th October 2021 06:44:43 AM

  1. 'use strict';
  2.  
  3. module.exports = key => {
  4.   if (key.ctrl) {
  5.     if (key.name === 'a') return 'first';
  6.     if (key.name === 'c') return 'abort';
  7.     if (key.name === 'd') return 'abort';
  8.     if (key.name === 'e') return 'last';
  9.     if (key.name === 'g') return 'reset';
  10.   }
  11.  
  12.   if (key.name === 'return') return 'submit';
  13.   if (key.name === 'enter') return 'submit'; // ctrl + J
  14.   if (key.name === 'backspace') return 'delete';
  15.   if (key.name === 'delete') return 'deleteForward';
  16.   if (key.name === 'abort') return 'abort';
  17.   if (key.name === 'escape') return 'abort';
  18.   if (key.name === 'tab') return 'next';
  19.   if (key.name === 'pagedown') return 'nextPage';
  20.   if (key.name === 'pageup') return 'prevPage';
  21.  
  22.   if (key.name === 'up') return 'up';
  23.   if (key.name === 'down') return 'down';
  24.   if (key.name === 'right') return 'right';
  25.   if (key.name === 'left') return 'left';
  26.  
  27.   return false;
  28. };

Raw Paste


Login or Register to edit or fork this paste. It's free.