@peter.naydenov/shortcuts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog.md +3 -0
- package/README.md +5 -1
- package/package.json +9 -5
- package/src/listen.js +2 -1
package/Changelog.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Define a context based keyboard-shortcuts and describe a mouse clicks. Switch among contexts.
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -11,6 +11,10 @@ Build a keyboard shortcuts maps and describe a mouse clicks. Control them on con
|
|
|
11
11
|
The shortcuts definition includes a context name and a set of rules(object). The rules are a set of key-value pairs. The key is a shortcut name and the value is a function or array of functions, to be executed when the shortcut is triggered (action function).
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
+
// { context: { shortcutName: actionFunction } }
|
|
15
|
+
// or
|
|
16
|
+
// { context: { shortcutName: [ actionFunction1, actionFunction2 ] }}
|
|
17
|
+
```
|
|
14
18
|
// Shortcut definition object:
|
|
15
19
|
{
|
|
16
20
|
contextName : {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.naydenov/shortcuts",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Context control of shortcuts based on keyboard and mouse events",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shortcut",
|
|
7
7
|
"key",
|
|
@@ -16,13 +16,17 @@
|
|
|
16
16
|
"build": "vite build",
|
|
17
17
|
"test": "cypress open --component --browser chrome test"
|
|
18
18
|
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/PeterNaydenov/shortcuts"
|
|
22
|
+
},
|
|
19
23
|
"dependencies": {
|
|
20
|
-
"@peter.naydenov/notice": "^2.1
|
|
24
|
+
"@peter.naydenov/notice": "^2.2.1"
|
|
21
25
|
},
|
|
22
26
|
"devDependencies": {
|
|
23
27
|
"@vitejs/plugin-react": "^4.0.4",
|
|
24
|
-
"chai": "^4.3.
|
|
25
|
-
"cypress": "^
|
|
28
|
+
"chai": "^4.3.8",
|
|
29
|
+
"cypress": "^13.2.0",
|
|
26
30
|
"mocha": "^10.2.0",
|
|
27
31
|
"react": "^18.2.0",
|
|
28
32
|
"react-dom": "^18.2.0",
|
package/src/listen.js
CHANGED
|
@@ -93,6 +93,7 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
|
|
|
93
93
|
|
|
94
94
|
function listenMouse () {
|
|
95
95
|
window.addEventListener ( 'contextmenu', event => { // Listen for right mouse clicks
|
|
96
|
+
event.preventDefault ()
|
|
96
97
|
clearTimeout ( mouseTimer )
|
|
97
98
|
if ( mouseIgnore ) {
|
|
98
99
|
clearTimeout ( mouseIgnore )
|
|
@@ -104,7 +105,6 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
|
|
|
104
105
|
mouseIgnore = setTimeout ( () => mouseIgnore=null, mouseWait )
|
|
105
106
|
return
|
|
106
107
|
}
|
|
107
|
-
event.preventDefault ()
|
|
108
108
|
mouseTarget = findTarget (event.target, clickTarget )
|
|
109
109
|
mouseDomEvent = event
|
|
110
110
|
count++
|
|
@@ -112,6 +112,7 @@ function listen ( dependencies, options, currentContext ) { // Listen for inpu
|
|
|
112
112
|
})
|
|
113
113
|
|
|
114
114
|
document.addEventListener ( 'click', event => { // Listen for left and middle mouse clicks
|
|
115
|
+
event.preventDefault ()
|
|
115
116
|
clearTimeout ( mouseTimer )
|
|
116
117
|
if ( mouseIgnore ) {
|
|
117
118
|
clearTimeout ( mouseIgnore )
|