New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flyd-keyboard

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flyd-keyboard - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

build-and-deploy-examples

43

index.js

@@ -5,3 +5,46 @@ var stream = require('flyd').stream;

var keycode = require('keycode');
var flyd = require('flyd');
var scanMerge = require('flyd-scanmerge');
exports.keysDown = function() {
var kd = stream();
var ku = stream();
var keysDown = scanMerge([
[kd, function(mem, c) {
return mem.concat(c);
}],
[ku, function(mem, c) {
return mem.filter(function(x) {
return x !== c;
});
}],
], []);
document.addEventListener('keydown', function(ev) {
// Prevent repeated events for the same key.
// dropRepeats can't be used on `kd` because it won't deactivate after
// `ku` has fired for the same key. Other (heavier?) option would be to
// do dropRepeatsWith(deepEqual) for keysDown.
var c = ev.keyCode;
if (keysDown().indexOf(c) < 0) kd(c);
}, false);
document.addEventListener('keyup', function(ev) {
ku(ev.keyCode);
}, false);
return keysDown;
};
exports.presses = function() {
var presses = stream();
document.addEventListener('keypress', function(ev) {
presses(ev.keyCode);
}, false);
return presses;
};
exports.key = function(key) {

@@ -8,0 +51,0 @@ var ks = stream(false);

3

package.json
{
"name": "flyd-keyboard",
"version": "1.0.1",
"version": "1.1.0",
"description": "Keyboard as Flyd streams",

@@ -15,2 +15,3 @@ "main": "index.js",

"flyd-droprepeats": "^2.0.0",
"flyd-scanmerge": "0.0.3",
"keycode": "^2.1.0"

@@ -17,0 +18,0 @@ },

@@ -5,6 +5,7 @@ # flyd-keyboard

__Arrows__
## API
### `arrows()`
```js
var kb = require('flyd-keyboard')
var arrows$ = kb.arrows();

@@ -15,6 +16,5 @@ arrows$(); // { x: 0, y: 0 }

__Key__
### `key()`
```js
var kb = require('flyd-keyboard')
var enter$ = kb.key('enter');

@@ -25,2 +25,18 @@ enter$(); // false

### `presses()`
Emits ASCII codes of pressed keys.
```js
var presses$ = kb.presses();
```
### `keysDown()`
Emits a list of keys as keycodes that are currently held down.
```js
var keysDown$ = kb.keysDown();
```
### examples

@@ -30,1 +46,3 @@

- [enter](http://raine.github.io/flyd-keyboard/enter)
- [presses](http://raine.github.io/flyd-keyboard/presses)
- [keysdown](http://raine.github.io/flyd-keyboard/keysdown)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc