From d98dcbeee4f0a0639551bd123c4b0a696831af30 Mon Sep 17 00:00:00 2001 From: Sven Minio Date: Sun, 17 May 2026 19:59:05 +0200 Subject: [PATCH] Add EVENTS Keyboard --- EVENTS-Keyboard.md | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 EVENTS-Keyboard.md diff --git a/EVENTS-Keyboard.md b/EVENTS-Keyboard.md new file mode 100644 index 0000000..526b3cc --- /dev/null +++ b/EVENTS-Keyboard.md @@ -0,0 +1,97 @@ +* [`keydown`](#usage-keydown) | [`keyup`](#usage-keyup) | [`keypress`](#usage-keypress) | [`pressedKey`](#usage-pressedKey) + +--- + +## .keydown + +**Description** +Bind an event handler to the "keydown" event, or trigger it. + +**Parameters** + +* `handler` (Function, optional): Function to execute. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$(document).keydown(function(e) { + console.log('Key pressed:', e.key); +}); + +``` + +--- + +## .keyup + +**Description** +Bind an event handler to the "keyup" event, or trigger it. + +**Parameters** + +* `handler` (Function, optional): Function to execute. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$('#input').keyup(function() { + console.log('Key released'); +}); + +``` + +--- + +## .keypress + +> **⚠️ DEPRECATED:** This event is officially deprecated in modern web standards. Please use [`.keydown()`](#usage-keydown) instead. + +**Description** +Bind an event handler to the "keypress" event, or trigger it. + +**Parameters** +* `handler` (Function, optional): Function to execute. + +**Returns** +* (jBase): Current instance. + +**Example** +```javascript +$(document).keypress(function(e) { + // Logic here +}); + +``` + +--- + +## .pressedkey + +**Description** +A specialized helper method. It attaches a listener that only executes the handler if a specific key matches. + +**Parameters** + +* `key` (String): The key value to check for (e.g., 'Enter', 'Escape'). +* `handler` (Function): Function to execute if the key matches. + +**Returns** + +* (jBase): Current instance. + +**Example** + +```javascript +$('#search').pressedkey('Enter', function() { + console.log('Enter key was pressed, submitting search...'); +}); + +``` \ No newline at end of file