scrapbook.js event handling cleanup

Minor cleanup: extracted a couple of methds for the keydown(…) event
handler.