$cmd

The $cmd function is a custom command handler designed to simplify the process of defining and executing commands based on keyboard events in JavaScript. It allows developers to specify key combinations and conditions under which a command should be executed.

$cmd(key, conditions, prevent, callback)

The $cmd function is a custom command handler designed to listen for keyboard events and execute a callback function under specific conditions.

Parameters:

Usage:

$cmd(key, conditions, prevent, callback)

Example:

// Example usage of $cmd
$cmd("s", "ctrlKey", true, function(event) {
    // Execute this function when Ctrl + S is pressed
    console.log("Ctrl + S pressed");
});

// or 
$cmd("s", "ctrlKey,shiftKey", false, function(event) {
    // Execute this function when Ctrl,shift + S is pressed
    console.log("Ctrl + S pressed");
});

In this example:
- The callback function logs a message to the console when the user presses Ctrl + S.
- The prevent parameter is set to true, preventing the default behavior of the keyboard event.

Notes:


This documentation should help users understand how to use the $cmd function effectively in their JavaScript code. If you have any further questions or need additional clarification, feel free to ask!