HTMLonkeyupイベント属性

❮HTMLイベント属性

ユーザーがキーを離したときにJavaScriptを実行します。

<input type="text" onkeyup="myFunction()">

以下の「自分で試してみてください」の例をもっと見てください。


定義と使用法

onkeyup属性は、ユーザーが(キーボードの)キーを離したときに起動します。

ヒント: onkeyupイベントに関連するイベントの順序:

  1. オンキーダウン
  2. onkeypress
  3. onkeyup

ブラウザのサポート

Event Attribute
onkeyup Yes Yes Yes Yes Yes

構文

<element onkeyup="script">

属性値

Value Description
script The script to be run on onkeyup

技術的な詳細

サポートされているHTMLタグ: <base>、<bdo>、<br>、<head>、<html>、<iframe>、<meta>、<param>、<script>、<style>、および<title>を除くすべてのHTML要素

その他の例

「onkeydown」を「onkeyup」属性と一緒に使用する:

<input type="text" onkeydown="keydownFunction()" onkeyup="keyupFunction()">

テキストフィールド内にリリースされた実際のキーを出力します。

Enter your name: <input type="text" id="fname" onkeyup="myFunction()">

<script>
function myFunction() {
  var x = document.getElementById("fname").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

関連ページ

HTML DOMリファレンス:onkeyupイベント


❮HTMLイベント属性