So, I want to be able to press enter while in a text field and be redirected to another page. Does anyone know how I can do this?
<input class="center" type="text" style="font-size:20px; border:none; outline:none; " size="105" type="text" placeholder="Shrek" name="search" >
Edit: Replaced single and double quotes.
const search = document.querySelector('[name="search"]');
search.addEventListener('keyup', (e) => {
if (e.code === 'Enter') {
const url = 'https://example.com/';
window.location.href = url;
}
});