Categories
Coding

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 + ")");
    }

    document.dispatchEvent(oEvent);
}
Detect.keydown(65);

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
Categories
Coding

Javascript detect keycodes tool

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

Javascript code is :

Categories
WordPress

Debian WordPress Permalink

404 Not found Error fix

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

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

Git remove large file wrongly committed

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

Integrating PHP in Apache

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/usr/local/etc/php/7.4/