ctrl enter opens url :)

This commit is contained in:
Ben Harris 2018-02-15 13:19:40 -05:00
parent d570d34c20
commit 2039aed6d5
1 changed files with 12 additions and 4 deletions

View File

@ -9,6 +9,17 @@
<title>newtab</title>
<link rel="stylesheet" href="https://tilde.team/css/hacker.css">
<script>
window.onload = function() {
document.getElementById('search')
.addEventListener('keydown', function(e) {
if (e.keyCode == 13) {
var q = document.getElementById('search').value;
window.location.replace(e.ctrlKey ? "http://" + q : "https://google.com/search?q=" + q);
}
}, false);
};
</script>
</head>
<body>
@ -19,10 +30,7 @@
<h1>new tab</h1>
</div>
<div class="col-md-8">
<form action="https://google.com/search">
<br>
<input class="form-control" tabindex="0" autofocus type="text" name="q" id="search">
</form>
<br><input class="form-control" autofocus type="text" name="q" id="search">
</div>
</div>
</div>