In-Browser Edition seems to have NumLock Disabled.

Discussions related to mouse, keyboard, fonts and Graphical User Interface
circe
Posts: 23
Joined: Wed 07 May 2025, 09:26

Re: In-Browser Edition seems to have NumLock Disabled.

Post by circe »

Somehow, we are not getting through to each other. Probably me!
Please load the simple program:
REM!Appname Keytest
PRINT"Press a Key:":REPEAT:x=INKEY(2000):PRINT'"Value="x"-Character="CHR$x;:PRINT:UNTILx=27

Now press Compile/Deploy as web App/Test.
Numeric key 5 should work as normal if Numlock ON, otherwise Nothing will happen.
Pressing keys 1-9 (except 5) will return two characters on my system.
And/Or
Load dlgdemo.bbc from examples and compile as Web App as above.
In the numeric entry field(top/right), which contains 123456, press 5 to confirm Numlock is ON. Now press 123456789 on the numeric pad. On my system, the field reads 971234565153, which cannot be right.
Do you get something different please?
Richard Russell
Posts: 702
Joined: Tue 18 Jun 2024, 09:32

Re: In-Browser Edition seems to have NumLock Disabled.

Post by Richard Russell »

circe wrote: Mon 06 Jul 2026, 14:28 Do you get something different please?
Yes, I get something different because - as stated multiple times - it depends on the state of NumLock when I run the program. I can make it work the same as you describe, or I can make it work correctly; depending on that choice of initial NumLock state.
circe
Posts: 23
Joined: Wed 07 May 2025, 09:26

Re: In-Browser Edition seems to have NumLock Disabled.

Post by circe »

Is there a Command or SYS that sets Numlock to ON, that can be incorporated into a program please?
Richard Russell
Posts: 702
Joined: Tue 18 Jun 2024, 09:32

Re: In-Browser Edition seems to have NumLock Disabled.

Post by Richard Russell »

circe wrote: Mon 06 Jul 2026, 21:05 Is there a Command or SYS that sets Numlock to ON, that can be incorporated into a program please?
Yes, SDL_SetModState, but unfortunately that's not currently exposed in the in-browser edition of BBCSDL.

As you may be aware, Emscripten - uniquely amongst platforms as far as I am aware - enforces run-time function signature checking. This obviously causes a major problem for implementing the SYS statement on that platform, since there's no mechanism by which you can tell SYS what the function signature is! :(

Therefore, as a crude workaround, the in-browser edition of BBCSDL includes a set of function wrappers, the sole purpose of which is to make those functions available with a uniform signature so they can be successfully called from a BASIC program using SYS. But to make this manageable only the most common functions are included, and SDL_GetModState() and SDL_SetModState() are not amongst them.

You could investigate whether there is a snippet of Javascript code that will set NumLock on. If there is, you can call the Javascript code using:

Code: Select all

SYS "emscripten_run_script_string", Javascript$, @memhdc%
These days, I use AI chatbots to research this kind of thing because they are far better at locating the relevant information than I am!