KaiOS Development ( Cursor Control ) Part 2

 Use Script 


<script>

// Variable to track state (starts as true)

let cursorActive = true;


// 1. Enable cursor automatically on app startup

window.addEventListener('DOMContentLoaded', function() {

  setCursorState(cursorActive);

});


// 2. Listen for the '1' key press to toggle

window.addEventListener('keydown', function(e) {

  if (e.key === '1') {

    e.preventDefault(); 

    cursorActive = !cursorActive; // Toggle state

    setCursorState(cursorActive);

  }

});


// Helper function to handle both KaiOS versions

function setCursorState(enable) {

  // KaiOS 3.0+

  if (navigator.b2g && navigator.b2g.virtualCursor) {

    if (enable) navigator.b2g.virtualCursor.enable();

    else navigator.b2g.virtualCursor.disable();

  } 

  // KaiOS 2.5

  else if ('spatialNavigationEnabled' in navigator) {

    navigator.spatialNavigationEnabled = enable;

  }

}

</script>

Comments

  1. What to u do if u aremt computer savy?i want to do that but dont understand?and not being mean all u hav to do i said b4 is test it with the actual phones work out the bugs and presto nothing to do but enjoy

    ReplyDelete

Post a Comment

Comment Here πŸ’¬