improve input subsystem.

[ENH] Improve input subsystem. Use multi-table to store keyboard states.
[FIX] Fixed the detection of release.