首页 > 解决方案 > HTML and JS on Windows only - input field does not generate onkeup/down events for non-english chars

问题描述

I have a very simple code with a text input box and a simple onkeyup handler. For some reason if my keyboard is in non-English language ( Russian, for example ) - they chars will be shown in the input field but no events will be generated. Pressing speace,enter or even arrows will generate the event and then the whole text is visible to the code.

This behavior is only like that on Windows ( IE, chrome, Edge ). On MAC it works as expected ( Chrome, Safari )

function line_Change(obj)
{
   alert("here");
}
  <input type="text" id="input1" onkeyup = "line_Change(this)" placeholder="Try typing something in here!">
  <label for="input1">Line 1</label>

EDIT: I found out that it does not work when connected to Windows from macOS thru TeamViewer. When working directly on Windows - the results are as expected

标签: javascripthtmlkey-eventsnon-english

解决方案


推荐阅读