<commit_before>'use strict';

var vkey = require('vkey');
var fromUnicode = require('./utext').fromUnicode;

// map virtual key to Unicode corresponding to trit-text, with modifiers
var _keymap = {
  // vkey: normal, shifted, control, shift-control
  A: ['a', 'A', '☺', ''],
  B: ['b', 'B', '☻', ''],
  C: ['c', 'C', '♥', ''],
  D: ['d', 'D', '♦', ''],
  E: ['e', 'E', '•', ''],
  F: ['f', 'F', '◘', ''],
  G: ['g', 'G', '○', ''],
  H: ['h', 'H', '◙', ''],
  I: ['i', 'I', '♂', ''],
  J: ['j', 'J', '♀', ''],
  K: ['k', 'K', '☼', ''],
  L: ['l', 'L', '▒', ''],
  M: ['m', 'M', '←', ''],
  N: ['n', 'N', '→', ''],
  O: ['o', 'O', '↑', ''],
  P: ['p', 'P', '↓', ''],
  Q: ['q', 'Q', '◄', ''],
  R: ['r', 'R', '►', ''],
  S: ['s', 'S', '▲', ''],
  T: ['t', 'T', '▼', ''],
  U: ['u', 'U', '', ''],
  V: ['v', 'V', '', ''],
  W: ['w', 'W', '', ''],
  X: ['x', 'X', '', ''],
  Y: ['y', 'Y', '', ''],
  Z: ['z', 'Z', '', ''],

  '`': ['`', '~', '', ''],
  1: ['1', '!', '', ''],
  2: ['2', '@', '', ''],
  3: ['3', '#', '', ''],
  4: ['4', '$', '', ''],
  5: ['5', '%', '', ''],
  6: ['6', '^', '', ''],
  7: ['7', '&', '', ''],
  8: ['8', '*', '', ''],
  9: ['9', '(', '', ''],
  0: ['0', ')', '', ''],
  '-': ['-', '_', '‾', ''],
  '=': ['=', '+', '', ''],
  '[': ['[', '{', '', ''],
  ']': [']', '}', '', ''],
  '\\': ['\\', '|', '', ''],
  ';': [';', ':', '', ''],
  '\'': ['\\', '"', '', ''],
  ',': [',', '<', '', ''],
  '.': ['.', '>', '', ''],
  '/': ['/', '?', '', ''],

  '<enter>': ['\n', '\n', '', ''],
};

function fromEvent(ev) {
  var vkeyChar = vkey[ev.keyCode];

  var flags = (ev.shiftKey ? 1 : 0) + (ev.ctrlKey ? 2 : 0); // TODO: metaKey(cmd)? altKey(opt)?

  var varChars = _keymap[vkeyChar];
  if (!varChars) return null;

  if (varChars[flags] === '' && flags === 3) flags = 2; // no shift-control variant, try control
  if (varChars[flags] === '' && flags === 2) flags = 0; // no control variant, try normal

  var c = varChars[flags];<commit_msg>Escape types escape, space space, control-space null, shift-= ≈<commit_after>'use strict';

var vkey = require('vkey');
var fromUnicode = require('./utext').fromUnicode;

// map virtual key to Unicode corresponding to trit-text, with modifiers
var _keymap = {
  // vkey: normal, shifted, control, shift-control
  A: ['a', 'A', '☺', ''],
  B: ['b', 'B', '☻', ''],
  C: ['c', 'C', '♥', ''],
  D: ['d', 'D', '♦', ''],
  E: ['e', 'E', '•', ''],
  F: ['f', 'F', '◘', ''],
  G: ['g', 'G', '○', ''],
  H: ['h', 'H', '◙', ''],
  I: ['i', 'I', '♂', ''],
  J: ['j', 'J', '♀', ''],
  K: ['k', 'K', '☼', ''],
  L: ['l', 'L', '▒', ''],
  M: ['m', 'M', '←', ''],
  N: ['n', 'N', '→', ''],
  O: ['o', 'O', '↑', ''],
  P: ['p', 'P', '↓', ''],
  Q: ['q', 'Q', '◄', ''],
  R: ['r', 'R', '►', ''],
  S: ['s', 'S', '▲', ''],
  T: ['t', 'T', '▼', ''],
  U: ['u', 'U', '', ''],
  V: ['v', 'V', '', ''],
  W: ['w', 'W', '', ''],
  X: ['x', 'X', '', ''],
  Y: ['y', 'Y', '', ''],
  Z: ['z', 'Z', '', ''],

  '`': ['`', '~', '', ''],
  1: ['1', '!', '', ''],
  2: ['2', '@', '', ''],
  3: ['3', '#', '', ''],
  4: ['4', '$', '', ''],
  5: ['5', '%', '', ''],
  6: ['6', '^', '', ''],
  7: ['7', '&', '', ''],
  8: ['8', '*', '', ''],
  9: ['9', '(', '', ''],
  0: ['0', ')', '', ''],
  '-': ['-', '_', '‾', ''],
  '=': ['=', '+', '≈', ''],
  '[': ['[', '{', '', ''],
  ']': [']', '}', '', ''],
  '\\': ['\\', '|', '', ''],
  ';': [';', ':', '', ''],
  '\'': ['\\', '"', '', ''],
  ',': [',', '<', '', ''],
  '.': ['.', '>', '', ''],
  '/': ['/', '?', '', ''],

  '<escape>': ['⌂', '⌂', '', ''],
  '<enter>': ['\n', '\n', '', ''],
  '<space>': [' ', '\u0000', ' ', ' '],
};

function fromEvent(ev) {
  var vkeyChar = vkey[ev.keyCode];

  var flags = (ev.shiftKey ? 1 : 0) + (ev.ctrlKey ? 2 : 0); // TODO: metaKey(cmd)? altKey(opt)?

  var varChars = _keymap[vkeyChar];
  if (!varChars) return null;

  if (varChars[flags] === '' && flags === 3) flags = 2; // no shift-control variant, try control
  if (varChars[flags] === '' && flags === 2) flags = 0; // no control variant, try normal

  var c = varChars[flags];
{'fraction_non_alphanumeric': 0.4722290792396939, 'fraction_numerical': 0.01481115773882992, 'mean_word_length': 2.9608993157380255, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2024632', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1890, 'n_words': 403}