re-frame

Ryan 2025-10-08T17:01:52.020619Z

What’s a good approach to trying to capture keyboard input from a barcode scanner in the form of !99999999999999\n ? is re-pressed able to dispatch an event with a variable sequence? It will be attached to 1 page but I’d rather not require the user to focus on a textfield to use the barcode scanner

Ryan 2025-10-08T17:02:25.611819Z

(I can also adjust the prefix character and end character)

gadfly361 2025-10-08T17:08:30.521469Z

Re-pressed only allows you to dispatch events that set up listeners for keyboard events. You don't have a mechanism to send keyboard events to re-pressed. https://github.com/gadfly361/re-pressed/blob/master/src%2Fmain%2Fre_pressed%2Fimpl.cljs#L149-L151

👍 1
Ryan 2025-10-08T17:12:05.781729Z

That’s fine, It’s listening to them, I can see it fire events for the !99999…99\n just fine, I just can’t figure out the syntax to get it to fire an event

gadfly361 2025-10-08T17:27:24.291349Z

In the readme look for

[{:keyCode 9} {:keyCode 9}]
I think you'll want to do something like that but with whatever sequence of keys you're expecting

gadfly361 2025-10-08T17:28:34.784459Z

And by something like that, I just mean putting the maps in an array like that, so then it'll match after that exact sequence (whatever you choose it to be)

Ryan 2025-10-08T17:30:48.069199Z

Ok so far so good.. I’m looking at that. Is there a way to specify a variable set of keys to capture between the ! and the \n? google AI thought there was but it looks like it might just be making stuff up again. something like [{:keycode 45 :shiftKey true} XXXXXXXXX {:keycode 13}]

gadfly361 2025-10-08T18:07:48.875029Z

Ah I understand now. No, that use case, where known keys sandwich unknown keys is not supported

gadfly361 2025-10-08T18:08:18.440509Z

You can only handle a sequence of known keys

Ryan 2025-10-08T18:14:25.959609Z

Thanks

gadfly361 2025-10-08T18:33:42.234389Z

Np