Skip to content

Commit

Permalink
v1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
CarcajadaArtificial committed Oct 22, 2024
1 parent a63ca56 commit 2e63108
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
- Event throttling/debouncing.
- Key hold detection.

## v1.0.8

- Changed `iKeystroke` to `Keystroke`.

## v1.0.7

- Added unit tests for the `isMacOS()` function.
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@carcajada/teclas",
"version": "1.0.7",
"version": "1.0.8",
"exports": "./mod.ts",
"tasks": {
"dev": "deno run --watch main.ts"
Expand Down
10 changes: 5 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface Event {
* keys to be pressed, an array of keys to be excluded, and a callback function to be executed when the
* keystroke combination is detected.
*/
export interface iKeystroke {
export interface Keystroke {
keys: CheckKeypress[];
except?: CheckKeypress[];
cb: (ev: Event) => void;
Expand All @@ -86,7 +86,7 @@ export type CheckKeypress = (ev: Event) => boolean;
* Function to check if a given keystroke combination is detected. It verifies that all keys in the
* `keys` array are pressed and all keys in the `except` array are not pressed.
*
* @param {iKeystroke} keystroke
* @param {Keystroke} keystroke
* The keystroke combination to check.
*
* @param {Event} ev
Expand All @@ -95,7 +95,7 @@ export type CheckKeypress = (ev: Event) => boolean;
* @returns {boolean}
* True if the keystroke combination is detected, false otherwise.
*/
export const checkKeystroke = (keystroke: iKeystroke, ev: Event): boolean =>
export const checkKeystroke = (keystroke: Keystroke, ev: Event): boolean =>
keystroke.keys.reduce<boolean>(
(accumulator, currentValue) => accumulator && currentValue(ev),
true,
Expand All @@ -111,13 +111,13 @@ export const checkKeystroke = (keystroke: iKeystroke, ev: Event): boolean =>
* Function to handle keyboard events based on an array of keystroke combinations. It checks each
* keystroke combination and executes the associated callback if the combination is detected.
*
* @param {iKeystroke[]} keystrokes
* @param {Keystroke[]} keystrokes
* An array of keystroke combinations to handle.
*
* @returns
* A function that processes keyboard events.
*/
export function handleKeyboard(keystrokes: iKeystroke[]): (ev: Event) => void {
export function handleKeyboard(keystrokes: Keystroke[]): (ev: Event) => void {
return (ev: Event) => {
keystrokes.forEach((keystroke) => {
if (checkKeystroke(keystroke, ev)) {
Expand Down

0 comments on commit 2e63108

Please sign in to comment.