We had old PDA machines with keypad and function keys and we have a web application that works on them made in classic ASP, jquery, and javascript. After the web application is opened, the user needs to press the F7 function to add a record for scanning a barcode.
Now the old PDA machines are dead and we are in process of purchasing android PDAs. The new machines don't have any keypad, it's just the touch screen. We tried adding a keyboard but there's not much space left on the screen to view the contents of the page and it is a bit tedious for the users.
Is there any way by which we can add a floater button on the page and by pressing it, it simulates function F7 press?
Thanks in advance.
The following script creates a button element which when clicked, initiates the clickF7 function which simulates F7 key press.
function clickF7() {
document.dispatchEvent(new KeyboardEvent('keydown', { 'key': 'f7' }))
}
const button = document.createElement('button')
button.innerHTML = 'click f7'
document.body.appendChild(button)
button.onclick = clickF7
document.addEventListener('keydown', function (e) {
if(e.key === 'f7') {
console.log('clicked f7')
}
})
EDIT: added listener to test keydown event
EDIT: tested on chrome