LoginSignup
3
3

More than 5 years have passed since last update.

【質問】iPadでbluetooth接続したキーボードから入力した場合(テキスト入力欄以外)のkeydownイベントの取得方法

Last updated at Posted at 2013-09-27

iPadでキーボードをbluetooth接続し、そのキーボードから入力した文字を取得したいと考えています。

その際、テキスト入力欄 <input type="text" id="aaa"> にフォーカスがある場合は以下の「onkeydown」イベントにて処理されますが、フォーカスが入力欄以外(ラジオボタンなど)にある場合このイベントが発生しません。

sample.html
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
document.onkeydown = function (e) {

  var chr = String.fromCharCode(e.keyCode);

  document.getElementById("aaa").value = document.getElementById("aaa").value + chr;
};
// -->
</script>
</head>
<body>
<form name="form1"  id="form1">
<input type="text" id="aaa">
<input type="radio" id="bbb" name="ccc">
</form>
</body>
</html>

どうすれば入力欄以外でも入力キーが取得できるのでしょうか?

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3