Caret XY Coordinate

Get INPUT and TEXTAREA Caret XY Coordinate.

HTML

<input dir="rtl" type="text" id="TEST_INPUT" onkeydown="myFunction(this)"/>
<div style="clear:both;"></div>
<textarea dir="rtl" id="TEST_TEXTAREA" onkeyup="myFunction(this)"></textarea>

JavaScript

/* Main Function
----------------------------------------------- */
function myFunction(Desired_ID){
    // Extra Codes Here ETC...
    document.getElementById(Desired_ID.id).style.backgroundColor = "red";
    // Extra Codes Here ETC...
    var coords = getSelectionCoords(Desired_ID);
    alert(coords.left + ", " + coords.top);
    // Extra Codes Here ETC...
}

/* Get Caret XY Coordinate
----------------------------------------------- */
function getSelectionCoords(Desired_ELEMENT) {
// ------>>> What To Do Here Is The Problem To Cover All Browsers <<<------
return {left:x,top:y};
}