- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 01:38 AM
Hi,
Can anybody help me realise ,how exactly can i implement the DOM KeyboardEvent functionality in servicenow.
I am trying to select some form elements(may not be fields,but html elements) and perform some action whenever i hit any keyboard button.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 01:58 AM
i checked your w3schools code and added to the UI Page and it's working.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<body>
<p>Press any key on the keyboard in the input field to get the Unicode character code and the Unicode key code of the pressed key.</p>
<p><strong>Note:</strong> The which and keyCode property does not work on the onkeypress event for non-printable, function keys (like CAPS LOCK, CTRL, ESC, F12, etc.).</p>
<input type="text" size="50" onkeypress="uniCharCode(event)" onkeydown="uniKeyCode(event)"> </input>
<p>onkeypress - <span id="demo"></span></p>
<p>onkeydown - <span id="demo2"></span></p>
<script>
function uniCharCode(event) {
var char = event.which || event.keyCode;
document.getElementById("demo").innerHTML = "The Unicode CHARACTER code is: " + char;
}
function uniKeyCode(event) {
var key = event.which || event.keyCode;
document.getElementById("demo2").innerHTML = "The Unicode KEY code is: " + key;
}
</script>
</body>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 01:54 AM
in service-now where exactly have you written ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 01:58 AM
i checked your w3schools code and added to the UI Page and it's working.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<body>
<p>Press any key on the keyboard in the input field to get the Unicode character code and the Unicode key code of the pressed key.</p>
<p><strong>Note:</strong> The which and keyCode property does not work on the onkeypress event for non-printable, function keys (like CAPS LOCK, CTRL, ESC, F12, etc.).</p>
<input type="text" size="50" onkeypress="uniCharCode(event)" onkeydown="uniKeyCode(event)"> </input>
<p>onkeypress - <span id="demo"></span></p>
<p>onkeydown - <span id="demo2"></span></p>
<script>
function uniCharCode(event) {
var char = event.which || event.keyCode;
document.getElementById("demo").innerHTML = "The Unicode CHARACTER code is: " + char;
}
function uniKeyCode(event) {
var key = event.which || event.keyCode;
document.getElementById("demo2").innerHTML = "The Unicode KEY code is: " + key;
}
</script>
</body>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2018 12:48 AM
Although i realised i was making a typo error, i would still mark ir correct. thanks for your efforts.