@aawd/assisted-input 中文文档教程
assisted-input
轻松将带有变音符号的字符添加到输入字段。 类似于(并受其启发)电话键盘如何让您按住一个键以获取相关键。 有关说明,请参阅此演示。
Installation
assisted-input
在 npm
上可用:
npm install --save @aawd/assisted-input
如果你只是想快速检查一下,克隆 repo,运行 express
服务器并打开http://localhost:9022
:
git clone https://github.com/aa-wd/assisted-input.git
npm run server:prod
Usage
将 data-assisted
作为属性添加到您需要帮助的输入中:
<!-- regular input -->
<input />
<!-- assisted input -->
<input data-assisted />
在您的 javascript 中,通过调用默认值来初始化辅助输入字段脚本export(我们将其命名为 createAssistedInputs
),其中包含一个以单个字符作为键的对象,以及一个以变音符号作为值的单个字符数组。
import createAssistedInputs from '@aawd/assisted-input';
createAssistedInputs({
'a': ['a', 'à', 'â', 'æ'],
'c': ['c', 'ç'],
'e': ['e', 'é', 'è', 'ê', 'ë'],
'i': ['i', 'î', 'ï'],
'o': ['o', 'ô', 'œ'],
'u': ['u', 'û', 'ü', 'ù'],
});
现在按住这些键中的任何一个(在示例中 a
、c
、e
、i
、o
, u
) 按下了一会儿。 有关更多说明,请参阅演示。
assisted-input
Easily add characters with a diacritic mark to an input field. Similar to (and inspired by) how phone keyboards allow you to hold a key pressed to get related keys. See this demo for instructions.
Installation
assisted-input
is available on npm
:
npm install --save @aawd/assisted-input
if you just quickly want to check it out, clone the repo, run the express
server and open http://localhost:9022
:
git clone https://github.com/aa-wd/assisted-input.git
npm run server:prod
Usage
Add data-assisted
as an attribute to inputs you want assistance for:
<!-- regular input -->
<input />
<!-- assisted input -->
<input data-assisted />
In your javascript, initialize the assisted input fields script by calling the default export (let's name it createAssistedInputs
) with an object that has single characters as keys, and an array of single characters with diacritic marks as values.
import createAssistedInputs from '@aawd/assisted-input';
createAssistedInputs({
'a': ['a', 'à', 'â', 'æ'],
'c': ['c', 'ç'],
'e': ['e', 'é', 'è', 'ê', 'ë'],
'i': ['i', 'î', 'ï'],
'o': ['o', 'ô', 'œ'],
'u': ['u', 'û', 'ü', 'ù'],
});
Now hold any of those keys (in the example a
, c
, e
, i
, o
, u
) pressed for a while. See the demo for more instructions.