Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/question/KeyCombo.ts>default#test

A module for deno to make interactive prompts in the terminal
Latest
method default.prototype.test
import { default } from "https://deno.land/x/question@0.0.2/KeyCombo.ts";

Test this key combination against a keyboard event. These events might come from events such as keydown and keyup.

Examples

Example 1

const saveKeyCombo = KeyCombo.parse('Ctrl+S')
if (saveKeyCombo.test(keypress)) {
  event.preventDefault()
  console.log('Saving...')
}

Parameters

event: Keypress

The event to test this key combo against.

Returns

boolean

True if the keys in the event matches the key combo.