dtio35880438 2016-10-23 23:59
浏览 44
已采纳

在网站中运行脚本,复制页面打开时按下的所有键[重复]

This question already has an answer here:

let me clear something up real fast- I'm not making a keylogger. I'm creating a site for a video game where users gain items for doing specific actions in game (such as typing something in chat, etc.).

Because of the way this game works, I feel the best way to do it would be to have a website that would, while open, record everything typed (and negate backspaces) to see if the player had completed the action. Then it would lead them onto the next action.

Is there a way to have a PHP or JavaScript script running inside of the website that would record all keystrokes that are typed while the page is open? Then I can have it just listen until it reads the player execute the command (such as joining a guild or trading somebody)?

-Vivian

</div>
  • 写回答

2条回答 默认 最新

  • dsjklb0205 2016-10-24 00:09
    关注

    Yes, its very easy to accomplish something like that with jQuery. Once you have included the lib, you can put certain events on elements. A way to set a key listener event, when the user releases the key would be something like this:

    $('body').keypress(function (event) {
        var character = String.fromCharCode(event.charCode)
        alert(character);
    });
    

    You can then send the result to php via AJAX (which you can also do pretty easy in jQuery (put this in a separate function and call the function in your keypress function):

    var url = 'your_script.php?character=' + character;
    $.get(url, function (data) {
        alert(data); // alert response from your_script.php
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c