Hacker News new | ask | show | jobs
by jmilkbal 4723 days ago
Perhaps map key codes to object properties with, you know, real names so comparisons to e.keyCode mean something in the future.

  var appKeys = { "Esc": 27 };

  else if (e.keyCode === appKeys.Esc) {
Some JS libs do this for you and there are some nice libs that make key handling convenient and powerful as well.
1 comments

Great tip. But I generally only use each reference once, so I'm not sure it would have been worth it in my case.

There are lots of libraries that could have made things more convenient. But a big part of this project was to learn as much as I could about coding, and the browser as an environment, so early on I committed to writing everything myself.

I'd be interested in hearing whether or not other people think this is a good strategy for self teaching.

+1 on doing everything yourself the first time for self-teaching. But I'm sure people are on the far end of both sides -- do it all yourself, or use libraries for everything.