---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.4
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/hi/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/ko/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/ru/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/tr/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/vi/sdk/defold/shortcut.md
  - https://yandex.com/dev/games/doc/zh/sdk/defold/shortcut.md
  - href: zh/sdk/defold/shortcut.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/zh/llms.txt

# 桌面快捷方式

<!-- source: zh/_includes/script-common.md -->
<!-- source: zh/_includes/script/index-js.md -->

<!-- endsource: zh/_includes/script/index-js.md -->

<!-- source: zh/_includes/script/requirements-js.md -->

<!-- endsource: zh/_includes/script/requirements-js.md -->

<!-- source: zh/_includes/script/image-modal-js.md -->

<!-- endsource: zh/_includes/script/image-modal-js.md -->
<!-- endsource: zh/_includes/script-common.md -->

通过使用原生对话框，您可以为用户提供将游戏链接添加为桌面快捷方式的选项。


在显示对话框之前，请先确保该选项可用。


## 检查是否可以添加快捷方式 {#can-add-shortcut}

选项是否可用，取决于平台、内部浏览器规则以及 [Yandex Games](https://yandex.com/games/){.external}的限制。为确保可以添加快捷方式，请使用 `ysdk.shortcut.can_show_prompt()` 方法：

```lua showLineNumbers
ysdk.shortcut.can_show_prompt(function (self, can_show)
  if can_show then
    -- 您可以在此处显示用于添加快捷方式的按钮。
  end
end)
```

## 打开对话框 {#dialog-box-open}

完成检查后，您可以在游戏内显示一个按钮（或不同的界面元素），点击该按钮即可调用添加快捷方式的对话框。要调用该对话框，请使用 `ysdk.shortcut.show_prompt()` 方法：

```lua showLineNumbers
ysdk.shortcut.show_prompt(function (self, accepted)
  if accepted then
    -- 您可以在此处提供添加快捷方式的奖励。
  end
end)
```

首次调用该方法时，将为 [Yandex Games](https://yandex.com/games/){.external} 目录创建快捷方式。如果快捷方式已经存在，将创建一个包含游戏链接的快捷方式。

---


<!-- source: zh/_includes/button-git.md -->
<a href="https://github.com/yandex-games-plugins/defold">
  <span class="button">存储库</span>
</a>
<!-- endsource: zh/_includes/button-git.md -->
