refactored code.
key down listener and update for figure are now in dedicated functions, stored under model