function waitForKeyPress() {
return new Promise(resolve => {
$('#textInput').once('keydown', event => {
if (event.keyCode === 13) {
resolve(event.keyCode);
}
});
});
}
Explain the above code in an extremely detailed and step by step yet beginner friendly manner with examples of modifications to the same and their result