diff --git a/index.js b/index.js index 860939f..ce11075 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ /**@type {HTMLDivElement} */ const h1 = document.querySelector('h1') const h2 = document.querySelector('h2') -h1.innerText='0.1.3' -h2.innerText='current event name' +h1.innerText = '0.1.3' +h2.innerText = 'current event name' const input = document.querySelector('input') const textarea = document.querySelector('textarea') input.addEventListener('keydown', handler) @@ -13,8 +13,9 @@ window.addEventListener('keydown', handler) * @param {MouseEvent} event */ function handler(event) { - h2.innerText=this===window ? 'window' :'input' - const { ctrlKey,shiftKey,altKey,metaKey, code,key,keyCode} = event - const info={ ctrlKey,shiftKey,altKey,metaKey, code,key,keyCode} - textarea.value = JSON.stringify(info,undefined,4) + h2.innerText = this === window ? 'window' : 'input' + const eventName = this === window ? 'window' : 'input' + const { ctrlKey, shiftKey, altKey, metaKey, code, key, keyCode } = event + const info = { ctrlKey, shiftKey, altKey, metaKey, code, key, keyCode } + textarea.value = `${eventName} ${JSON.stringify(info, undefined, 4)} \n\r${textarea?.value}` } \ No newline at end of file