Disable Backspace key across browsers

amak
amak Community Member Posts: 23
Hi there,

 

Has anyone had experience disabling the backspace key so users can't navigate to the previous page? We have a course that the client requested the backspace to be disabled as it causes a long string of LMSInitialize error pop ups. So far I have tried a RunJavaScript action with:

 

window.onkeydown = function(e) {
if (e.keyCode == 8 && e.target == document.body)
e.preventDefault();
}

 

This was tested in SCORM Cloud on Chrome, IE and Firefox, however IE is the only one that doesn't work.

I also tried the same code above as an external HTML object set as header scripting which gave the same result.

Does anyone have any suggestions as to how this can be achieved across multiple browsers? We are using Lectora V16.1.2.

 

Thanks in advance!

Comments

  • amak
    amak Community Member Posts: 23
    Hi again,

     

    I've also tried adding a keystroke action to the title level, set the key to "backspace" and left the action as "No action" but this still didn't work. Setting the action to GoTo, Target: Current Page, Scroll to: Top of Page, Open in: Existing Window also didn't work in IE11 and Firefox.
  • jasonadal
    jasonadal Community Member Posts: 441 ♪ Opening Act ♪
    My initial response to this is "NOOOOOOO!!!!!" for accessibility reasons. However, I did a quick StackOverflow search and found that it may be possible and there's a working demo in the thread.

    If you absolutely have to do this, I would say that you have to heavily emphasize this prior to the user entering the section. For keyboard only or screen reader users, this is a significant barrier.

    Realistically, I would emphasize that would not be compliant with ADA and WCAG and recommend they work with their LMS to get this fixed. Otherwise, they are putting themselves at risk for a lawsuit. Even private business are subject to the regulations and susceptible to litigation.
  • amak
    amak Community Member Posts: 23
    Hi Jason,

    Thanks for your reply! Accessibility is a factor in this course and is addressed early on with an option for a text based version. So while the course won't necessarily be 'accessible' the alternative text version will cater to those who require it. I gave the StackOverflow link a go and it worked to a certain extent. The message would pop up if I tried going back or clicking the backspace key, however it would also pop up whenever I wanted to progress through the course with the navigation buttons built into the course. I'll keep trying though!
  • amak
    amak Community Member Posts: 23
    Hi everyone,

    The client has indicated that in fact disabling the backspace key isn't required but rather it should be replaced with another function. So a backspace keystroke action has been used with the Exit/Close action. No LMSInitialize error pop ups appear when the backspace is clicked and it simply closes the course. Bookmarking is enabled so learners can return and continue from where they left off.

    Also, as advised by Microsoft, disabling the backspace can't be done in IE:

    It is by-design; you cannot disable the backspace option on internet explorer.

    https://answers.microsoft.com/en-us/ie/forum/ie8-windows_other/how-do-i-disable-the-backspace-button-on-the/0e2cf333-1f0d-474d-800f-56a6da17f083

     

     

     
  • carlfink
    carlfink Community Member Posts: 971 ✭ Legend ✭
    You can disable the "navigate to previous page" (and next page) functionality instead of the keystroke itself, using
    try {
    history.forward();
    } catch (e) {
    }