Skip to content

feat: add k.cancel() #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2024
Merged

feat: add k.cancel() #545

merged 2 commits into from
Nov 29, 2024

Conversation

neverUsedGithub
Copy link
Contributor

@neverUsedGithub neverUsedGithub commented Nov 28, 2024

Description

Adds support for k.cancel(), a new way to cancel events in KAPLAY. As discussed on Discord, k.cancel is a method (when it could just be a property) to signify that it has an "action", to maybe help beginners better understand it.

k.onKeyPress((key) => {
    if (key === "q") return k.cancel();
});

Copy link

pkg-pr-new bot commented Nov 28, 2024

Open in Stackblitz

npm i https://pkg.pr.new/kaplayjs/kaplay@545

commit: 1606060

src/types.ts Outdated
Comment on lines 5512 to 5524
/**
* Cancels the event if returned.
*
* @since v3001.1
* @group Events
* @example
* ```js
* onKeyPress((key) => {
* if (key === "q") return k.cancel();
* });
* ```
*/
cancel: () => Symbol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the correct format described in Contributing.md

@lajbel lajbel merged commit b91b393 into kaplayjs:master Nov 29, 2024
2 checks passed
lajbel pushed a commit that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants