با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
راهنما میانبرهای صفحه کلید به کاربران امکان می دهد میانبرهای صفحه کلید را برای پلتفرم پیدا کنند و برنامه ها را باز کنند. میانبرهای برنامه خود را در Helper Shortcuts Keyboard منتشر کنید تا بهره وری کاربر و سهولت استفاده را بهبود ببخشید.
کاربران Meta+/ را فشار می دهند تا صفحه میانبرهای صفحه کلید باز شود، که در اندروید 7.0 (سطح API 24) و بالاتر در دسترس است.
شکل 1. راهنما میانبرهای صفحه کلید.
میانبرهایی را برای Helper Shortcuts Keyboard ارائه دهید
میتوانید فهرستهای میانبر صفحهکلید موجود را با نادیده گرفتن فراخوانی پنجره onProvideKeyboardShortcuts() برای Helper Shortcuts Keyboard ارائه دهید. قطعه زیر اجرای onProvideKeyboardShortcuts() برای افزودن یک گروه از چهار میانبر نشان می دهد:
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 به لیست قابل تغییر ارسال شده به عنوان اولین پارامتر روش، میانبرهای صفحه کلید موجود را به Helper میانبرهای صفحه کلید اطلاع میدهند.
میانبرهای صفحه کلید را با گروه ها سازماندهی کنید
Helper میانبرهای صفحه کلید میانبرهای صفحه کلید را در گروههای جداگانه نمایش میدهد تا کاربران بتوانند میانبرها را با استفاده از حروف یا صفحههای برنامه شما پیدا کنند. شکل 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)}
راهنمای میانبرهای صفحه کلید را از کد باز کنید
برنامه ها صفحه میانبرهای صفحه کلید را با فراخوانی متد requestShowKeyboardShortcuts() نمایش می دهند. در قطعه زیر، وقتی کاربران روی دکمه ضربه می زنند یا کلیک می کنند یا کلید Enter را فشار می دهند، Helper Shortcuts Keyboard باز می شود.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],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 }"]]