You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@langfreak/convert-layout

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langfreak/convert-layout

Converts text from one keyboard layout to other

0.11.2
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
0
Weekly downloads
 
Created
Source

Convert Layout

NOTE: The upstream package was deprecated with this message "Use KeyboardEvent#code in keyup event." I couldn't find a way for that to substitute how I was using this package, so I created this fork.

A JavaScript library to convert text from one keyboard layout to other.

Useful to prevent errors on english-only fields, like a credit card owner field.

var ru = require('convert-layout/ru');

bankcardName.keyup(function () {
  bankcardName.value = ru.toEn(bankcardName.value);
});

The upstream package was sponsored by Evil Martians. Sponsored by Evil Martians

This fork is sponsored by Langfreak where it is used as part of the virtual keyboard implementation which lets language learners type with the keyboard layout of their target language, without having to change their OS settings to support it.

Usage

There are two ways to load a keyboard layout definition. If you plan on using a single layout, just load the file directly:

var ru = require('convert-layout/ru');

Also you can get a object with all layouts (but app size will be bigger):

var layouts = require('convert-layout');
layout = layouts[name];

Every layout has fromEn and toEn methods:

ru.toEn('руддщ')    //=> "hello"
ru.fromEn('ghbdtn') //=> "привет"

Layouts

Currently supported keyboard layouts:

  • Arabic
  • Belarusian
  • English (QWERTY, Dvorak, Colemak)
  • French
  • Italian
  • Georgian
  • German
  • Greek
  • Hungarian
  • Kazakh
  • Korean
  • Russian
  • Spanish
  • Swedish
  • Turkish
  • Ukrainian
  • Hebrew
  • Persian
  • Czech

If you want to add a new keyboard layout definition:

  • Fork a project. Create a branch.
  • Add a CODE.json file with layout buttons map. See example in ru.json. Lower case letters will be converted to upper case automatically. However, all non-letters symbols should be added both in uppercase and lowercase.
  • Run yarn test. Project will be built automatically.
  • Add layout to the list above.
  • Send a pull request.

Keywords

keyboard

FAQs

Package last updated on 12 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.