Skip to content

Commit

Permalink
add method for waiting for a "continue" keypress
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryMoon committed Feb 8, 2025
1 parent 8cded2c commit 80ed611
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/public-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,19 @@

}


/**
* Waits for the user to press a key to continue.
*
* @returns {Promise<void>} Resolves when the user presses a key.
*/
beep8.Async.waitForContinue = async function() {

while ( true ) {
const key = await beep8.Async.key();
if ( key.includes( "Enter" ) || key.includes( "ButtonA" ) ) break;
}

}

} )( beep8 || ( beep8 = {} ) );
5 changes: 4 additions & 1 deletion src/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
* The text can contain embedded newlines and they will behave as expected:
* printing will continue at the next line.
*
* Fonts use the defined tile size as their dimensions. Each character will
* be one tile. By default the tile size is: 12x12 pixels.
*
* If PRINT_ESCAPE_START and PRINT_ESCAPE_END are defined in CONFIG, then
* you can also use escape sequences. For example:
* - {{c1}} sets the color to 1
Expand Down Expand Up @@ -248,7 +251,7 @@
/**
* Prints text centered horizontally in a field of the given width.
*
* If the text is bigger than the width, it will overflow it.
* If the text is bigger than the width, it will wrap.
*
* @param {string} text - The text to print.
* @param {number} width - The width of the field, in characters.
Expand Down

0 comments on commit 80ed611

Please sign in to comment.