Skip to content

Instantly share code, notes, and snippets.

@dpfrakes
Created April 18, 2020 14:25
Show Gist options
  • Save dpfrakes/67929e2be2ea2314e1938b2362586e72 to your computer and use it in GitHub Desktop.
Save dpfrakes/67929e2be2ea2314e1938b2362586e72 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const readline = require('readline');
const moment = require('moment-timezone');
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
if (key.ctrl && key.name === 'c') {
process.exit();
} else {
let d = moment().tz("America/New_York").format();
fs.appendFile('movie-timestamps.txt', `${d} - [${key.name}]\n`, () => { console.log(key.name); });
}
});
console.log('Press any key...');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment