-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (24 loc) · 770 Bytes
/
script.js
File metadata and controls
33 lines (24 loc) · 770 Bytes
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
const input =document.getElementById('input');
const button =document.getElementById('button');
const result =document.getElementById('result');
const body =document.getElementById('body');
const url = "https://api.dictionaryapi.dev/api/v2/entries/en/";
const sushil = ()=> {
let word=input.value;
fetch(url+word)
.then (data=>data.json())
.then(e=>
{
// console.log(e);
result.innerHTML="<b>"+e[0].meanings[0].definitions[0].definition+"</b>";
})
}
button.addEventListener("click",sushil);
document.addEventListener('keydown', (event) => {
var name = event.key;
var code = event.code;
// Alert the key name and key code on keydown
if(name=="s"){
sushil();
}
}, false);