本文介绍了如何在chrome扩展中获取按键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我创建了一个谷歌浏览器扩展程序来获取活动标签中的按键值。



Hi guys,

I have created one google chrome extension to get key pressed values from active tab.

<!DOCTYPE html>

<html>
    <head>
        <script src="popup.js"></script>
    </head>
        <body>
            <h3><center>Key Logger</center></h3>
            <hr>
            <label>Unable/Disable</label><input type="checkbox" name="chk" id="chk">
            <br />
            <textarea name="sdata" id="sdata" cols="30" rows="10"></textarea>       
        </body>
</html>







var x;var y="";var d = new Date();
myFunction();
function myFunction(event) {
    x = event.which || event.keyCode;
    //alert(x);
    y += x == 13 ? "<br />" : String.fromCharCode(x);
    document.getElementById("sdata").innerHTML = d + "<br />" + y;
}





我的尝试:



Manifest.json



What I have tried:

Manifest.json

{
    "name":"Key Logger",
    "description":"It will store all the keys used during browsing.",
    "version":"1.0.0",
    "manifest_version": 2,
    "browser_action":{
        "default_icon":"icon.png",
        "default_popup":"popup.html"
    },
    "content_scripts": [
        {
          "matches": ["*://*/*"],
          "js": ["popup.js"]
        }
      ],
    "permissions":[
        "tabs",
        "storage",
        "activeTab"
    ]
}





可以有人请帮助我。如何从活动标签中获取按下的键值。



提前谢谢。



Can anyone please help me. How to get the key pressed value from active tab.

Thanks in advance.

推荐答案


这篇关于如何在chrome扩展中获取按键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 19:10