How to use the readchar.key.CTRL_D function in readchar

To help you get started, we’ve selected a few readchar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kamik423 / cutie / test / test_prompt_yes_or_no.py View on Github external
def test_ctrl_d_abort(self, *m):
        with InputContext(readchar.key.CTRL_D):
            with self.assertRaises(KeyboardInterrupt):
                cutie.prompt_yes_or_no("")
github Kamik423 / cutie / test / test_prompt_yes_or_no.py View on Github external
def test_ctrl_d_abort_with_input(self, *m):
        with InputContext(readchar.key.UP, readchar.key.CTRL_D):
            with self.assertRaises(KeyboardInterrupt):
                cutie.prompt_yes_or_no("")
github Kamik423 / cutie / test / test_select.py View on Github external
def test_keyboard_interrupt_ctrl_d_no_input(self, *m):
        with InputContext(readchar.key.CTRL_D):
            with self.assertRaises(KeyboardInterrupt):
                cutie.select(["foo"])
github Kamik423 / cutie / test / test_select.py View on Github external
def test_keyboard_interrupt_ctrl_d_selected(self, *m):
        with InputContext(readchar.key.DOWN, readchar.key.CTRL_D):
            with self.assertRaises(KeyboardInterrupt):
                cutie.select(["foo"], selected_index=0)
github Kamik423 / cutie / cutie.py View on Github external
init()


class DefaultKeys:
    """List of default keybindings.

    Attributes:
        interrupt(List[str]): Keys that cause a keyboard interrupt.
        select(List[str]): Keys that trigger list element selection.
        confirm(List[str]): Keys that trigger list confirmation.
        delete(List[str]): Keys that trigger character deletion.
        down(List[str]): Keys that select the element below.
        up(List[str]): Keys that select the element above.
    """
    interrupt: List[str] = [readchar.key.CTRL_C, readchar.key.CTRL_D]
    select: List[str] = [readchar.key.SPACE]
    confirm: List[str] = [readchar.key.ENTER]
    delete: List[str] = [readchar.key.BACKSPACE]
    down: List[str] = [readchar.key.DOWN, 'j']
    up: List[str] = [readchar.key.UP, 'k']


def get_number(
        prompt: str,
        min_value: Optional[float] = None,
        max_value: Optional[float] = None,
        allow_float: bool = True) -> float:
    """Get a number from user input.
    If an invalid number is entered the user will be prompted again.

    Args:

readchar

Library to easily read single chars and key strokes

MIT
Latest version published 2 months ago

Package Health Score

88 / 100
Full package analysis

Similar packages