classMainActivity:ComponentActivity(){// Activity codes such as overridden onStart method.overridefunonProvideKeyboardShortcuts(data:MutableList<KeyboardShortcutGroup>?,menu:Menu?,deviceId:Int){valshortcutGroup=KeyboardShortcutGroup("Cursor movement",listOf(KeyboardShortcutInfo("Up",KeyEvent.KEYCODE_P,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Down",KeyEvent.KEYCODE_N,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Forward",KeyEvent.KEYCODE_F,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Backward",KeyEvent.KEYCODE_B,KeyEvent.META_CTRL_ON),))data?.add(shortcutGroup)}}
KeyboardShortcutInfo는 단축키를 설명합니다.
단축키 목록은
KeyboardShortcutGroup 객체
앱에서 다음을 추가하여 사용 가능한 단축키를 단축키 도우미에 알립니다.
KeyboardShortcutGroup 객체를 전달된 변경 가능한 목록에 추가합니다.
를 메서드의 첫 번째 매개변수로 사용합니다.
그룹으로 단축키 정리하기
단축키 도우미가 단축키를 별도의 그룹으로 표시
이를 통해 사용자는 사용 사례별 또는 화면별 단축키를 찾을 수 있습니다.
있습니다. 그림 2에 단축키가 나와 있습니다.
커서 이동과 메시지 수정이라는 두 그룹으로 분류됩니다.
그림 2. 단축키 도우미의 카테고리입니다.
앱은
각 그룹의 KeyboardShortcutGroup 객체입니다.
다음 스니펫에서는 두 개의 KeyboardShortCutGroup 객체가
onProvideKeyboardShortcuts() 메서드에 전달된 변경 가능한 목록입니다.
개체는 단축키 도우미에서
그림 2에서 볼 수 있습니다.
overridefunonProvideKeyboardShortcuts(data:MutableList<KeyboardShortcutGroup>?,menu:Menu?,deviceId:Int){valcursorMovement=KeyboardShortcutGroup("Cursor movement",listOf(KeyboardShortcutInfo("Up",KeyEvent.KEYCODE_P,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Down",KeyEvent.KEYCODE_N,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Forward",KeyEvent.KEYCODE_F,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Backward",KeyEvent.KEYCODE_B,KeyEvent.META_CTRL_ON),))valmessageEdit=KeyboardShortcutGroup("Message editing",listOf(KeyboardShortcutInfo("Select All",KeyEvent.KEYCODE_A,KeyEvent.META_CTRL_ON),KeyboardShortcutInfo("Send a message",KeyEvent.KEYCODE_ENTER,KeyEvent.META_SHIFT_ON)))data?.add(cursorMovement)data?.add(messageEdit)}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Keyboard Shortcuts Helper enables users to discover keyboard shortcuts for the\nplatform and open apps. Publish your app's shortcuts in Keyboard Shortcuts Helper\nto improve user productivity and ease of use.\n\nUsers press \u003ckbd\u003eMeta+/\u003c/kbd\u003e to open the keyboard shortcuts screen, which is\navailable on [Android 7.0](/about/versions/nougat/android-7.0#keyboard_shortcuts_helper) (API level 24) and higher.\n**Figure 1.** Keyboard Shortcuts Helper. **Note:** The Meta key is not present on all keyboards. On macOS keyboards, the Meta key is the Command key; on Windows keyboards, the Windows key; and on ChromeOS keyboards, the Search key.\n\nProvide shortcuts to Keyboard Shortcuts Helper\n----------------------------------------------\n\nYou can provide available keyboard shortcut lists to\nKeyboard Shortcuts Helper by overriding the\n[`onProvideKeyboardShortcuts()`](/reference/kotlin/android/view/Window.Callback#onprovidekeyboardshortcuts) window callback.\nThe following snippet demonstrates an implementation of\n`onProvideKeyboardShortcuts()` to add a group of four shortcuts: \n\n class MainActivity : ComponentActivity() {\n // Activity codes such as overridden onStart method.\n\n override fun onProvideKeyboardShortcuts(\n data: MutableList\u003cKeyboardShortcutGroup\u003e?,\n menu: Menu?,\n deviceId: Int\n ) {\n val shortcutGroup = KeyboardShortcutGroup(\n \"Cursor movement\",\n listOf(\n KeyboardShortcutInfo(\"Up\", KeyEvent.KEYCODE_P, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Down\", KeyEvent.KEYCODE_N, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Forward\", KeyEvent.KEYCODE_F, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Backward\", KeyEvent.KEYCODE_B, KeyEvent.META_CTRL_ON),\n )\n )\n data?.add(shortcutGroup)\n }\n }\n\n[`KeyboardShortcutInfo`](/reference/kotlin/android/view/KeyboardShortcutInfo) describes a keyboard shortcut.\nThe list of keyboard shortcuts are wrapped as a\n[`KeyboardShortcutGroup`](/reference/kotlin/android/view/KeyboardShortcutGroup) object.\nApps notify available keyboard shortcuts to Keyboard Shortcuts Helper by adding\nthe `KeyboardShortcutGroup` objects to the mutable list passed\nas the first parameter of the method.\n\nOrganize keyboard shortcuts with groups\n---------------------------------------\n\nKeyboard Shortcuts Helper displays keyboard shortcuts in separate groups\nso users can find shortcuts by use case or for screens of\nyour app. [Figure 2](/static/images/develop/ui/touch-input/keyboard-input/keyboard_shortcut_group.png) shows the keyboard shortcuts\ncategorized into two groups: cursor movement and message editing.\n**Figure 2.** Categories in Keyboard Shortcuts Helper.\n\nYour app registers two or more groups of keyboard shortcuts by creating a\n`KeyboardShortcutGroup` object for each group.\nIn the following snippet, two `KeyboardShortCutGroup` objects are added to the\nmutable list passed to the `onProvideKeyboardShortcuts()` method.\nThe objects are displayed as categories in Keyboard Shortcuts Helper as\n[figure 2](/static/images/develop/ui/touch-input/keyboard-input/keyboard_shortcut_group.png) shows. \n\n override fun onProvideKeyboardShortcuts(\n data: MutableList\u003cKeyboardShortcutGroup\u003e?,\n menu: Menu?,\n deviceId: Int\n ) {\n val cursorMovement = KeyboardShortcutGroup(\n \"Cursor movement\",\n listOf(\n KeyboardShortcutInfo(\"Up\", KeyEvent.KEYCODE_P, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Down\", KeyEvent.KEYCODE_N, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Forward\", KeyEvent.KEYCODE_F, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Backward\", KeyEvent.KEYCODE_B, KeyEvent.META_CTRL_ON),\n )\n )\n\n val messageEdit = KeyboardShortcutGroup(\n \"Message editing\",\n listOf(\n KeyboardShortcutInfo(\"Select All\", KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON),\n KeyboardShortcutInfo(\"Send a message\", KeyEvent.KEYCODE_ENTER, KeyEvent.META_SHIFT_ON)\n )\n )\n\n data?.add(cursorMovement)\n data?.add(messageEdit)\n }\n\nOpen Keyboard Shortcuts Helper from code\n----------------------------------------\n\nApps display the keyboard shortcuts screen by\ncalling the [`requestShowKeyboardShortcuts()`](/reference/kotlin/android/app/Activity#requestshowkeyboardshortcuts)\nmethod. In the following snippet, Keyboard Shortcuts Helper opens when users tap\nor click the button or press the \u003ckbd\u003eEnter\u003c/kbd\u003e key. \n\n val activity = LocalContext.current as Activity\n\n Button(onClick = { activity.requestShowKeyboardShortcuts() }) {\n Text(text = \"Show keyboard shortcuts\")\n }"]]