How to prevent user to press ESC key

  • #1, by AkcayKaraazmakSaturday, 19. September 2015, 16:19 5 years ago
    Hi guys,

    As you know, when a video is been playing, if you press ESC then it skips the video. I want to control this. I dont want user to skip all the videos but just the ones I want. How I can do it, any ideas? smile

    Cheers

    Great Poster

    437 Posts


  • #2, by afrlmeSaturday, 19. September 2015, 16:41 5 years ago
    You need to use the registerEventHandler function to disable the ESC key as needed.

    function keyboardHandler(eventType, character, keycode, modifiers)
    if Conditions["enable_esc"].ConditionValue == false and keycode == eKeyEscape then return true end
    return false
    end

    registerEventHandler("keyEvent", "keyboardHandler")
    1
    2
    3
    4
    5
    6
    7


    Add the above script as a definition script. Create a condition anywhere you like (somewhere easy to access / remember) & name it enable_esc. Then to enable / disable the ESC key, just toggle the condition between true & false. True = enabled. False = disabled. Simple. wink

    P.S: I'm not sure if this works for videos. The last time I tried it (earlier 4.x build) it did not prevent the skipping of videos. It did prevent ESC in general & skipping of cut-scenes. I believe I asked for an option a while ago in the dev tracker for preventing the skipping of videos. I don't know if it will get added or not mind.

    Imperator

    6842 Posts

  • #3, by AkcayKaraazmakSaturday, 19. September 2015, 16:47 5 years ago
    Thank you so much Leesmile I'll try it asap smile

    Great Poster

    437 Posts

  • #4, by AkcayKaraazmakSunday, 20. September 2015, 11:42 5 years ago
    It worked super mate!! grin Thank you so much!

    Great Poster

    437 Posts

  • #5, by afrlmeSunday, 20. September 2015, 12:13 5 years ago
    So it does prevent skipping of videos now too? Nice one.

    By the way, did you know that it's now possible for players to pause videos with the space bar key? If you set a pause screen image in the main game tab, then it should fade in / show as an overlay whenever a player pauses a video.

    Imperator

    6842 Posts

  • #6, by AkcayKaraazmakSunday, 20. September 2015, 12:21 5 years ago
    Ye ye you cant skip them now with your code! smile .. Aa ye I accidently found that, pausing them with space bar smile

    Thank you as always!

    Great Poster

    437 Posts

Write post