Shortcut for a button on the template

I am currently using this script to create a button on clicking which it shows me an extra field.

<div id="ID" style="display:none">{{Text}}</div>

<button class="button" type="button"  onclick="
        if
            (document.getElementById('ID') .style.display=='none')
            {document.getElementById('ID') .style.display=''}
        else
            {document.getElementById('ID') .style.display='none'}">
    Show Answer
</button>

I 'd like to know a way to show the text not only by mouse but also by keyboard.

Try this, it should work, and to choose the key put the key code you want (from: https://keycode.info) instead of key 90:

<Script>
window.onkeyup = function(e) {
        var key = e.keyCode ? e.keyCode : e.which;
        if (key == 90) {
if
            (document.getElementById('ID') .style.display=='none')
            {document.getElementById('ID') .style.display=''}
        else
            {document.getElementById('ID') .style.display='none'}
        }
    }
</script>