rewored key event handling and double tracking of changes to avoid lost edits bug