Fix undomanager typing state with modifier keys

Hi there - I ran into this when writing some custom unit tests to confirm behavior of the UndoManager, and was surprised to find that e.g. the Cmd-A (or Ctrl-A) keystroke to select all flips the typing state of UndoManager to true. I'm not sure if my proposed fix here is the exact way you think it should be fixed, but the unit test I altered does seem to effectively capture the problem and is alleviated by the fix.