How can one use ExamineKeyboard() (the Keyboard library) without a Screen?
In the examples I can only see these commands used within a BindEvent(#PB_Event_RenderFrame, @callback())
I just started coding in SB this evening; the first think I need is a Console library, and I wanted to implement it in a Window, in TextGadgets.
ExamineKeyboard in main loop without Screen
Re: ExamineKeyboard in main loop without Screen
One half solution would be to
!document.addEventListener('keydown', function(event) { f_processeventkeycode(event.keyCode); });
but keycodes are too low level - they get 'a', but not 'A' nor 'â'. Which is probably the same that the Keyboard library gets. I suppose for my purpose I want something different.
!document.addEventListener('keydown', function(event) { f_processeventkeycode(event.keyCode); });
but keycodes are too low level - they get 'a', but not 'A' nor 'â'. Which is probably the same that the Keyboard library gets. I suppose for my purpose I want something different.
Re: ExamineKeyboard in main loop without Screen
Code: Select all
Procedure InitKey(callback)
! document.addEventListener('keypress', (event) => {
! const keyName = event.key;
! v_callback(keyName);
! })
EndProcedure
;// Zone test
Procedure Dummy(Key.s)
Debug Key
EndProcedure
OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_Background)
InitKey(@Dummy())
➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
➽ http://falsam.com
Sorry for my poor english
Re: ExamineKeyboard in main loop without Screen
Right, special combinations like for example [AltGr]+[Shift]+[^], [e] → 'ê' do not work.falsam wrote:This code does not detect Alt, Ctrl, F1->F12, Escape keys.
So, I am resorting (for the specific purpose I had) to a TextGadget for the output + a StringGadget for the input, adding a
!spider_GadgetID(v_inputstringgadget).div.addEventListener('keydown', function(event) { f_inputgadgetkeydown(event.keyCode); });
to detect the [ENTER] key and trigger the "after string completed" process.