Skip to content
Centurion

Shortcuts

Shortcuts provide a way to execute commands using key combinations. They can be configured with one or more key combinations.

Configuration

Shortcuts can be enabled or disabled by configuring the shortcutsEnabled option on the client.

Shortcuts are enabled by default.

Centurion.client({
shortcutsEnabled: false,
});

Usage

In the following example, the command is configured to execute when the user presses E or LeftAlt + E.

@Register()
export class EchoCommand {
@Command({
name: "echo",
description: "Prints a message",
shortcuts: [Enum.KeyCode.E, [Enum.KeyCode.LeftAlt, Enum.KeyCode.E]]
})
run(ctx: CommandContext) {
print("Echo!");
}
}

Shortcuts can also be configured to execute the command with arguments.

In this example, when the user presses LeftAlt + E, it will pass the given argument(s) to the command, printing Hello, world!.

If the user presses E, no arguments will be provided and Echo! will be printed.

@Register()
export class EchoCommand {
@Command({
name: "echo",
description: "Prints a message",
shortcuts: [
Enum.KeyCode.E,
{
keys: [Enum.KeyCode.LeftAlt, Enum.KeyCode.E],
args: ["Hello, world!"]
},
}]
})
run(ctx: CommandContext, text?: string) {
if (text !== undefined) {
print(text);
} else {
print("Echo!");
}
}
}