-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_escape.py
More file actions
44 lines (34 loc) · 1.2 KB
/
Copy pathtest_escape.py
File metadata and controls
44 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
"""Test script for ESC key detection."""
import time
from rich.console import Console
from aws_hit_breaks.cli.keyboard import (
escape_listener,
poll_escape,
is_cancelled,
reset_cancel,
)
console = Console()
def main():
console.print("[bold]ESC Key Detection Test[/bold]")
console.print("=" * 40)
console.print()
console.print("[dim]Press ESC to test cancellation...[/dim]")
console.print("[dim]The test will run for 10 seconds.[/dim]")
console.print()
with escape_listener(console):
for i in range(10):
# Poll for ESC key
poll_escape()
if is_cancelled():
console.print()
console.print("[yellow]ESC detected! Cancellation requested.[/yellow]")
console.print("[green]Test successful - ESC key is working![/green]")
return
console.print(f"Waiting... {10 - i} seconds remaining. Press ESC to cancel.")
time.sleep(1)
console.print()
console.print("[red]ESC was not detected during the test.[/red]")
console.print("Try pressing ESC more firmly or check terminal compatibility.")
if __name__ == "__main__":
main()