0

I'm writing a script which leverages keypresses, and I have need of detecting whether or not the user is in insert mode or overwrite mode.

Fortunately overwrite mode is not a thing in Firefox, Chrome, or Safari, but it is in Edge.

I've done copious amounts of searching and the only applicable code I have found is:

document.queryCommandValue("OverWrite");

However this seems to have gone unsupported since IE11 from what I can gather. In Edge it returns an empty string regardless of whether or not you are in insert mode.

I've tried using document.queryCommandState('OverWrite'); instead, however likewise it always returns false.

Is anyone aware of the new way to test for this, assuming it is a thing that is possible to test for?

Scoots
  • 3,048
  • 2
  • 21
  • 33

1 Answers1

0

I try to test it with MS Edge and I am able to produce the issue. It can be possible that it is some kind of bug or the Edge team needs to add the support of the API. I will try to submit the feedback regarding this issue.

As a workaround, you could refer to this answer. You could use the jsfiddle demo in the answer to detect the overwrite mode in Edge. But the draw back of the function is when you add characters at the end of the inputs, the mode detect will not work.

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22
  • Hey, thanks for your reply. I found that answer you linked to prior to posting this, however sadly it's not applicable to my situation (I require an update on every key entry into the field. If someone holds down a key then it is not detected by keyup until they release the key) – Scoots Oct 28 '19 at 13:00
  • We have tested and think this a bug of Edge. We can't detect the overwrite mode in Edge now. We have opened [an issue](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/23800385/). You could follow the link. Thanks for your understanding. – Yu Zhou Oct 29 '19 at 01:38