Project.js: tidy up key handling

 - reorganise onkeydown function for readability
 - check if a tool provides a handleKeyPress function before accessing it.
Add onkeyup to project.js

This allows tools to receive the keyup event.