JavaScript keypress detection script

Method 1

Detect = {};
Detect.keydown = function(k) {
    var oEvent = document.createEvent("KeyboardEvent");

    // Chromium Hack
    Object.defineProperty(oEvent, "keyCode", {
                get : function() {
                    return this.keyCodeVal;
    Object.defineProperty(oEvent, "which", {
                get : function() {
                    return this.keyCodeVal;

    if (oEvent.initKeyboardEvent) {
        oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, true, false, false, false, k, k);
    } else {
        oEvent.initKeyEvent("keydown", true, true, document.defaultView, true, false, false, false, k, 0);

    oEvent.keyCodeVal = k;

    if (oEvent.keyCode !== k) {
        alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");


Method 2

document.dispatchEvent(new window.KeyboardEvent("keydown", {key: "a", char: "a", keyCode: 65, ctrlKey:false}));

Method 3

var e = jQuery.Event("keydown");
e.which = 65;       // # G code value
e.ctrlkey = false;     // control key pressed
jQuery(document).trigger(e);// trigger event on document

Javascript detect keycodes tool

Type a key on your keyboard to find the key code / keyboard code

Javascript code is :


Debian WordPress Permalink

404 Not found Error fix

Add the below code in /etc/apache2/apache2.conf

<Directory /var/www/html/>
AllowOverride All
sudo a2enmod rewrite
sudo systemctl restart apache2

Git remove large file wrongly committed

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git push

Create MikroTik image

Download the raw disk image archive from Mikrotik


Unzip the archive

unzip chr-6.42rc30.img

Expand the image size to 1GB

truncate --size=1G chr-6.42rc30.img

Create the image archive for Google GCE

mv chr-6.42rc30.img disk.raw tar -Sczf chr-6.42rc30-image.tar.gz disk.raw

To upload in Google cloud

Create a bucket to store image archives

gsutil mb gs://cloud-hosted-router-images

Copy the new image to the bucket

gsutil cp chr-6.42rc30.tar.gz gs://cloud-hosted-router-images

Create a Google cloud image

Create an image for GCE from the archive

gcloud compute images create "routeros"
--description "Mikrotik Cloud Hosted Router (CHR) for running as a virtual machine."
--source-uri ""

Create MikroTik instance

Create an instance

gcloud compute instances create "chr-1"
--zone "us-central1-c"
--machine-type "f1-micro"

For Mac

For truncate:

brew install truncate
truncate -s 1G chr-6.42rc30.img

For gnu-tar:

brew install gnu-tar
gtar -Sczf chr-6.42rc30.tar.gz disk.raw