未验证 提交 177547a0 编写于 作者: P PingPing2023 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-inputdevice.md.

Signed-off-by: NPingPing2023 <pingping@huawei.com>
上级 d6467882
...@@ -34,7 +34,7 @@ getDeviceList(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void ...@@ -34,7 +34,7 @@ getDeviceList(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
```js ```js
try { try {
inputDevice.getDeviceList((error, ids) => { inputDevice.getDeviceList((error: Error, ids: Array<number>) => {
if (error) { if (error) {
console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -129,7 +129,7 @@ getDeviceInfo(deviceId: number): Promise&lt;InputDeviceData&gt; ...@@ -129,7 +129,7 @@ getDeviceInfo(deviceId: number): Promise&lt;InputDeviceData&gt;
```js ```js
// 获取输入设备id为1的设备信息。 // 获取输入设备id为1的设备信息。
try { try {
inputDevice.getDeviceInfo(1).then((deviceData) => { inputDevice.getDeviceInfo(1).then((deviceData: inputDevice.InputDeviceData) => {
console.log(`Device info: ${JSON.stringify(deviceData)}`); console.log(`Device info: ${JSON.stringify(deviceData)}`);
}); });
} catch (error) { } catch (error) {
...@@ -194,7 +194,7 @@ off(type: "change", listener?: Callback&lt;DeviceListener&gt;): void ...@@ -194,7 +194,7 @@ off(type: "change", listener?: Callback&lt;DeviceListener&gt;): void
**示例** **示例**
```js ```js
function callback(data) { function callback(data: inputDevice.DeviceListener) {
console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`); console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`);
}; };
...@@ -292,7 +292,7 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi ...@@ -292,7 +292,7 @@ getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): voi
```js ```js
// 获取输入设备id为1的设备信息。 // 获取输入设备id为1的设备信息。
inputDevice.getDevice(1, (error, deviceData) => { inputDevice.getDevice(1, (error: Error, deviceData: inputDevice.InputDeviceData) => {
if (error) { if (error) {
console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -327,7 +327,7 @@ getDevice(deviceId: number): Promise&lt;InputDeviceData&gt; ...@@ -327,7 +327,7 @@ getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
```js ```js
// 获取输入设备id为1的设备信息。 // 获取输入设备id为1的设备信息。
inputDevice.getDevice(1).then((deviceData) => { inputDevice.getDevice(1).then((deviceData: inputDevice.InputDeviceData) => {
console.log(`Device info: ${JSON.stringify(deviceData)}`); console.log(`Device info: ${JSON.stringify(deviceData)}`);
}); });
``` ```
...@@ -387,7 +387,7 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;b ...@@ -387,7 +387,7 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;b
```js ```js
// 查询id为1的输入设备对于17、22和2055按键的支持情况。 // 查询id为1的输入设备对于17、22和2055按键的支持情况。
try { try {
inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult) => { inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult: Array<boolean>) => {
console.log(`Query result: ${JSON.stringify(supportResult)}`); console.log(`Query result: ${JSON.stringify(supportResult)}`);
}); });
} catch (error) { } catch (error) {
...@@ -415,7 +415,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): ...@@ -415,7 +415,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;):
```js ```js
// 查询id为1的输入设备的键盘类型。 // 查询id为1的输入设备的键盘类型。
try { try {
inputDevice.getKeyboardType(1, (error, type) => { inputDevice.getKeyboardType(1, (error: Error, type: number) => {
if (error) { if (error) {
console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -481,7 +481,7 @@ setKeyboardRepeatDelay(delay: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -481,7 +481,7 @@ setKeyboardRepeatDelay(delay: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputDevice.setKeyboardRepeatDelay(350, (error) => { inputDevice.setKeyboardRepeatDelay(350, (error: Error) => {
if (error) { if (error) {
console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Set keyboard repeat delay failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -579,7 +579,7 @@ getKeyboardRepeatDelay(): Promise&lt;number&gt; ...@@ -579,7 +579,7 @@ getKeyboardRepeatDelay(): Promise&lt;number&gt;
```js ```js
try { try {
inputDevice.getKeyboardRepeatDelay().then(delay => { inputDevice.getKeyboardRepeatDelay().then((delay: number) => {
console.log(`Get keyboard repeat delay success`); console.log(`Get keyboard repeat delay success`);
}); });
} catch (error) { } catch (error) {
...@@ -608,7 +608,7 @@ setKeyboardRepeatRate(rate: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -608,7 +608,7 @@ setKeyboardRepeatRate(rate: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputDevice.setKeyboardRepeatRate(60, (error) => { inputDevice.setKeyboardRepeatRate(60, (error: Error) => {
if (error) { if (error) {
console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Set keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -674,7 +674,7 @@ getKeyboardRepeatRate(callback: AsyncCallback&lt;number&gt;): void ...@@ -674,7 +674,7 @@ getKeyboardRepeatRate(callback: AsyncCallback&lt;number&gt;): void
```js ```js
try { try {
inputDevice.getKeyboardRepeatRate((error, rate) => { inputDevice.getKeyboardRepeatRate((error: Error, rate: number) => {
if (error) { if (error) {
console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`); console.log(`Get keyboard repeat rate failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return; return;
...@@ -706,7 +706,7 @@ getKeyboardRepeatRate(): Promise&lt;number&gt; ...@@ -706,7 +706,7 @@ getKeyboardRepeatRate(): Promise&lt;number&gt;
```js ```js
try { try {
inputDevice.getKeyboardRepeatRate().then(rate => { inputDevice.getKeyboardRepeatRate().then((rate: number) => {
console.log(`Get keyboard repeat rate success`); console.log(`Get keyboard repeat rate success`);
}); });
} catch (error) { } catch (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册