Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keyboard-layout

Package Overview
Dependencies
Maintainers
6
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyboard-layout - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

.node-version

94

lib/keyboard-layout.js

@@ -1,50 +0,66 @@

(function() {
var Emitter, KeyboardLayoutObserver, emitter, getCurrentKeyboardLanguage, getCurrentKeyboardLayout, getInstalledKeyboardLanguages, observeCurrentKeyboardLayout, observer, onDidChangeCurrentKeyboardLayout;
'use strict'
Emitter = require('event-kit').Emitter;
const Emitter = require('event-kit').Emitter
const KeyboardLayoutManager = require('../build/Release/keyboard-layout-manager.node')
KeyboardLayoutObserver = require('../build/Release/keyboard-layout-observer.node').KeyboardLayoutObserver;
const emitter = new Emitter()
emitter = new Emitter;
let currentKeymap = null
let currentKeyboardLayout = null
let currentKeyboardLanguage = null
observer = new KeyboardLayoutObserver(function() {
return emitter.emit('did-change-current-keyboard-layout', getCurrentKeyboardLayout());
});
const manager = new KeyboardLayoutManager(() => {
currentKeymap = null
currentKeyboardLayout = null
currentKeyboardLanguage = null
emitter.emit('did-change-current-keyboard-layout', getCurrentKeyboardLayout())
})
getCurrentKeyboardLayout = function() {
return observer.getCurrentKeyboardLayout();
};
function getCurrentKeymap () {
if (!currentKeymap) {
currentKeymap = manager.getCurrentKeymap()
}
return currentKeymap
}
getCurrentKeyboardLanguage = function() {
return observer.getCurrentKeyboardLanguage();
};
function getCurrentKeyboardLayout () {
if (!currentKeyboardLayout) {
currentKeyboardLayout = manager.getCurrentKeyboardLayout()
}
return currentKeyboardLayout
}
getInstalledKeyboardLanguages = function() {
var language, languages, _i, _len, _ref;
languages = {};
_ref = observer.getInstalledKeyboardLanguages() || [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
language = _ref[_i];
languages[language] = true;
}
return Object.keys(languages);
};
function getCurrentKeyboardLanguage () {
if (!currentKeyboardLanguage) {
currentKeyboardLanguage = manager.getCurrentKeyboardLanguage()
}
return currentKeyboardLanguage
}
onDidChangeCurrentKeyboardLayout = function(callback) {
return emitter.on('did-change-current-keyboard-layout', callback);
};
function getInstalledKeyboardLanguages () {
var languages = {}
observeCurrentKeyboardLayout = function(callback) {
callback(getCurrentKeyboardLayout());
return onDidChangeCurrentKeyboardLayout(callback);
};
for (var language of (manager.getInstalledKeyboardLanguages() || [])) {
languages[language] = true
}
module.exports = {
getCurrentKeyboardLayout: getCurrentKeyboardLayout,
getCurrentKeyboardLanguage: getCurrentKeyboardLanguage,
getInstalledKeyboardLanguages: getInstalledKeyboardLanguages,
onDidChangeCurrentKeyboardLayout: onDidChangeCurrentKeyboardLayout,
observeCurrentKeyboardLayout: observeCurrentKeyboardLayout
};
return Object.keys(languages)
}
}).call(this);
function onDidChangeCurrentKeyboardLayout (callback) {
return emitter.on('did-change-current-keyboard-layout', callback)
}
function observeCurrentKeyboardLayout (callback) {
callback(getCurrentKeyboardLayout())
return onDidChangeCurrentKeyboardLayout(callback)
}
module.exports = {
getCurrentKeymap: getCurrentKeymap,
getCurrentKeyboardLayout: getCurrentKeyboardLayout,
getCurrentKeyboardLanguage: getCurrentKeyboardLanguage,
getInstalledKeyboardLanguages: getInstalledKeyboardLanguages,
onDidChangeCurrentKeyboardLayout: onDidChangeCurrentKeyboardLayout,
observeCurrentKeyboardLayout: observeCurrentKeyboardLayout
}
{
"name": "keyboard-layout",
"version": "1.0.1",
"version": "1.1.0",
"description": "Read and observe the current keyboard layout on OS X.",
"main": "./lib/keyboard-layout",
"scripts": {
"prepublish": "grunt prepublish",
"test": "grunt test"
"test": "jasmine-focused --captureExceptions --forceexit spec"
},

@@ -28,13 +27,4 @@ "repository": {

"devDependencies": {
"coffee-script": "^1.7.0",
"jasmine-focused": "^1.0.4",
"grunt-contrib-coffee": "^0.9.0",
"grunt-cli": "^0.1.8",
"grunt": "^0.4.1",
"grunt-shell": "^0.2.2",
"grunt-coffeelint": "^0.0.6",
"rimraf": "^2.2.2",
"coffee-cache": "^0.2.0",
"temp": "^0.6.0"
"jasmine-focused": "^1.0.4"
}
}

@@ -9,5 +9,5 @@ # keyboard-layout [![Build Status](https://travis-ci.org/atom/keyboard-layout.svg?branch=master)](https://travis-ci.org/atom/keyboard-layout) [![Build status](https://ci.appveyor.com/api/projects/status/303xcfrs0yj448au/branch/master?svg=true)](https://ci.appveyor.com/project/kevinsawicki/keyboard-layout/branch/master)

```coffee
{getCurrentKeyboardLayout} = require 'keyboard-layout'
getCurrentKeyboardLayout() # => "com.apple.keylayout.Dvorak"
```js
const KeyboardLayout = require('keyboard-layout')
KeyboardLayout.getCurrentKeyboardLayout() // => "com.apple.keylayout.Dvorak"
```

@@ -19,8 +19,27 @@

current layout value and then again next time it changes, whereas
`onDidChangeCurrentKeyboardLayout` only invokes the callback on the next change.
`onDidChangeCurrentKeyboardLayout` only invokes the callback on the next
change.
```coffee
{observeCurrentKeyboardLayout} = require 'keyboard-layout'
subscription = observeCurrentKeyboardLayout (layout) -> console.log layout
subscription.dispose() # to unsubscribe later
```js
const KeyboardLayout = require('keyboard-layout')
subscription = KeyboardLayout.observeCurrentKeyboardLayout((layout) => console.log(layout))
subscription.dispose() // to unsubscribe later
```
To return characters for various modifier states based on a DOM 3
`KeyboardEvent.code` value and the current system keyboard layout, use
`getCurrentKeymap()`:
```js
const KeyboardLayout = require('keyboard-layout')
KeyboardLayout.getCurrentKeymap()['KeyS']
/*
On a US layout, this returns:
{
unmodified: 's',
withShift: 'S',
withAltGr: 'ß',
withShiftAltGr: 'Í'
}
*/
```

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