key-event-to-string
Advanced tools
Comparing version 1.0.0 to 1.1.0
17
index.js
@@ -69,2 +69,17 @@ var defaultOptions = { | ||
function details (e) { | ||
var map = buildKeyMap(e) | ||
var mods = map.modifiers | ||
var hasModifier = mods.cmd || mods.ctrl || mods.alt || mods.shift | ||
var result = { | ||
hasKey: map.character != null, | ||
hasModifier: hasModifier, | ||
map: map | ||
} | ||
return result | ||
} | ||
module.exports = function (userOptions) { | ||
@@ -74,1 +89,3 @@ options = Object.assign(defaultOptions, userOptions) | ||
} | ||
module.exports.details = details |
{ | ||
"name": "key-event-to-string", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": " Converts a JavaScript key event object into a humanly readable format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -55,2 +55,14 @@ # JavaScript keyboard events to strings | ||
### Detailed information | ||
`event2string.details(e)` can be used to get more details. This can be useful for | ||
validating keyboard shortcuts, e.g. for requiring a modifier and a normal key. | ||
It returns an object with this information: | ||
- `hasModifier`: True iff atleast one of cmd, ctrl, alt or shift was pressed | ||
- `hasKey`: True iff a key other than a modifier is pressed | ||
- `map`: An object containing information which modifier is active and what | ||
other key is pressed | ||
## Disclaimer | ||
@@ -57,0 +69,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6833
74
72