We can create a <kbd> element via the document.createElement()
method:
var x = document.createElement("KBD");
Click the button to create a KBD element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from www. j a v a2 s .c o m var x = document.createElement("KBD"); var t = document.createTextNode("Keyboard input text"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>