From c9e19a2fe3d7e4222c23c0a29bfe710a95e48103 Mon Sep 17 00:00:00 2001 From: limeng Date: Thu, 6 Apr 2023 14:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng --- .../ts-universal-events-keyboardshortcut.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-keyboardshortcut.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-keyboardshortcut.md index cf1d55550b..c51ba19e47 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-keyboardshortcut.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-keyboardshortcut.md @@ -14,10 +14,10 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[CtrlKey]>) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ------------------------------------- | ---- | ------------------------------------------------------------ | -| value | string \| [FunctionKey](#FunctionKey) | 是 | 热键的单个字符(可以通过键盘输入的字符)或[FunctionKey](#FunctionKey)。
| -| keys | Array<[CtrlKey](#CtrlKey)> | 是 | 热键组合。
| +| value | string \| [FunctionKey](#functionkey) | 是 | 热键的单个字符(可以通过键盘输入的字符)或[FunctionKey](#functionkey)。
| +| keys | Array<[CtrlKey](#ctrlkey)> | 是 | 热键组合。
| -## CtrlKey枚举说明 +## CtrlKey | 名称 | 描述 | | ----- | ------------------- | @@ -25,7 +25,7 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[CtrlKey]>) | SHIFT | 表示键盘上Shift键。 | | ALT | 表示键盘上Alt键。 | -## FunctionKey枚举说明 +## FunctionKey | 名称 | 描述 | | ---- | --------------------- | @@ -80,6 +80,7 @@ keyboardShortcut(value: string | [FunctionKey], keys: Array<[CtrlKey]>) 设置组件的快捷键,同时按控制键+对应的字符可以触发组件响应快捷键,并触发onClick事件或自定义事件。 ```ts +// xxx.ets @Entry @Component struct Index { @@ -92,15 +93,18 @@ struct Index { Button("Test short cut 1").onClick((event) => { this.message = "I clicked Button 1"; console.log("I clicked 1"); - }).keyboardShortcut('.', [CtrlKey.SHIFT, CtrlKey.CTRL, CtrlKey.ALT]) + }).keyboardShortcut('.', [ModifierKey.SHIFT, ModifierKey.CTRL, ModifierKey.ALT]) + .onKeyEvent((event)=>{ + console.log("event.keyCode: " + JSON.stringify(event)); + }) Button("Test short cut 2").onClick((event) => { this.message = "I clicked Button 2"; console.log("I clicked 2"); - }).keyboardShortcut('1', [CtrlKey.CTRL]) + }).keyboardShortcut('1', [ModifierKey.CTRL]) Button("Test short cut 3").onClick((event) => { this.message = "I clicked Button 3"; console.log("I clicked 3"); - }).keyboardShortcut('A', [CtrlKey.CTRL]) + }).keyboardShortcut('A', [ModifierKey.SHIFT]) Button("Test short cut 4").onClick((event) => { this.message = "I clicked Button 4"; console.log("I clicked 4"); -- GitLab