تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتيح "مساعد اختصارات لوحة المفاتيح" للمستخدمين اكتشاف اختصارات لوحة المفاتيح
النظام الأساسي وفتح التطبيقات. نشر اختصارات تطبيقك في "مساعد اختصارات لوحة المفاتيح"
لتحسين إنتاجية المستخدم وسهولة الاستخدام.
يضغط المستخدمون على /Meta+ لفتح شاشة اختصارات لوحة المفاتيح، وهي
متوفّرة على Android 7.0 (المستوى 24 لواجهة برمجة التطبيقات) والإصدارات الأحدث.
الشكل 1. مساعد اختصارات لوحة المفاتيح
توفير اختصارات لمساعد اختصارات لوحة المفاتيح
يمكنك تقديم قوائم اختصارات لوحة المفاتيح المتاحة
مساعد اختصارات لوحة المفاتيح من خلال تجاوز
رد الاتصال بالفترة onProvideKeyboardShortcuts().
يوضح المقتطف التالي تنفيذ
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 إلى القائمة القابلة للتغيير
باعتبارها المعلمة الأولى للطريقة.
تنظيم اختصارات لوحة المفاتيح باستخدام المجموعات
يعرض "مساعد اختصارات لوحة المفاتيح" اختصارات لوحة المفاتيح في مجموعات منفصلة
بحيث يمكن للمستخدمين العثور على اختصارات حسب حالة الاستخدام أو لشاشات
تطبيقك. يعرض الشكل 2 اختصارات لوحة المفاتيح
مصنفة إلى مجموعتين هما: حركة المؤشر وتعديل الرسالة.
الشكل 2. الفئات في مساعد اختصارات لوحة المفاتيح.
يسجِّل تطبيقك مجموعتين أو أكثر من اختصارات لوحة المفاتيح من خلال إنشاء
عنصر KeyboardShortcutGroup لكل مجموعة.
في المقتطف التالي، تمت إضافة كائنين KeyboardShortCutGroup إلى العنصر
تم تمرير قائمة قابلة للتغيير إلى الطريقة onProvideKeyboardShortcuts().
يتم عرض الكائنات كفئات في مساعد اختصارات لوحة المفاتيح
يعرضه figure 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.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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 }"]]