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