-4

I want to insert a System date using a keyboard shortcut in a textarea. Something exactly like excel Ctrl+; (semi-colon)

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
Wande
  • 1
  • 2
  • 1
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – Marco Salerno Nov 28 '17 at 13:46
  • https://stackoverflow.com/questions/5203407/javascript-multiple-keys-pressed-at-once please check this question – suhail c Nov 28 '17 at 13:46
  • Good luck! As an aside, if you want help with your ambitions, you may want to read both: "*[ask]*" and "*[mcve].*" – David Thomas Nov 28 '17 at 13:47
  • Maybe take the [tour] as well as read [ask]. – freedomn-m Nov 28 '17 at 13:51

1 Answers1

-1
<html>
<head>
    <title>KeyEvent</title>
</head>
<body>

    <script type='text/javascript'>
        function KeyPress(e) {
            var evtobj = window.event? event : e

            if (evtobj.keyCode == 90 && evtobj.ctrlKey) {
             var currDate = new Date();
             document.getElementById("textareaTest").innerHTML = currDate;

            };
        }

        document.onkeydown  = KeyPress;
    </script>
<textarea id="textareaTest" onkeydown="KeyPress(e)"></textarea>
</body>
</html>

CTRL+z will insert current date in the above code, manipulate the date format in whichever format required

HulkSapien
  • 157
  • 2
  • 9
  • this is fine but ctr+z clears my comment before inserting the date. I want the date to be appended to my comment – Wande Nov 28 '17 at 14:11