Implemented frame based logic.

Add many rules.
Add key autorepeat.