reading simultaneous keys pressed - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: reading simultaneous keys pressed (/showthread.php?tid=385) |
reading simultaneous keys pressed - nitrofurano - 10-08-2011 i forgot how to read simultaneous keys pressed on zx-spectrum - is it from port 254? and only port 254? and how? and how can we read them in a zxbasic-compiler snippet? thanks! Re: reading simultaneous keys pressed - boriel - 10-08-2011 Use the multikeys function in the library which returns non zero (True) if ANY of the given keys is pressed. Code: #include <keys.bas> Notice you can use | as in C or bOR to test for multiple values simultaneously. So the above test checks for ENTER or SPACE pressed. The function is much faster than INKEY$ and can check multiple keys pressing (limited by the ZX hardware) Re: reading simultaneous keys pressed - nitrofurano - 10-09-2011 it doens't work... - are you sure this snippet and the used library are working fine? the code (in the spectrum) looks like hanging - it doesn't provide any feedback btw, has ./library/keys.bas 3535 bytes, 147 lines, and the md5sum is 8eb7625442d3c108ee6b90ded47aff8c? Code: guest@macbook_mint1 /mnt/sda4/trabalhos/programacao/8bit/zxspectrum/ftpupload/zxspectrumstuff_20111001/borielzxbasiccompiler/_sandboxes/_sandbox_03 $ zxb.py -tB Re: reading simultaneous keys pressed - boriel - 10-09-2011 You have to execute zxb.py --version in the same directory zxb.py is installed, and must have write permissions on such directory. The snippet is not working, that's right, because I forgot you have to check simultaneously KEYS in the same semirow (look at the ZX Spectrum keyboard layout). E.g. The following will work: Code: #include <keys.bas> MultiKeys(<key 1>) AND MultiKeys(<Key 2>) Re: reading simultaneous keys pressed - nitrofurano - 10-09-2011 btw, i started trying these snippets: (and found how to get keyboard values directly from 'in' command) this works, but i'm not very fan of this complexity of values, which makes me struggling when using similar stuff with games with redefinable keys (like those from Dinamic and so on) Code: 10 print at 0,0;" " i wanted to do this (but the code doesn't works...) Code: function getkey(kv as ubyte) as ubyte and when i tried to figure out what were going wrong, this code hangs (like 'usr 0') Code: dim v3 as uinteger Re: reading simultaneous keys pressed - boriel - 10-09-2011 It seems we crospost. Let me repeat here: The snippet is not working, that's right, because I forgot you have to check simultaneously KEYS in the same semirow (look at the ZX Spectrum keyboard layout). E.g. The following will work: Code: #include <keys.bas> Re: reading simultaneous keys pressed - nitrofurano - 10-09-2011 yes, it works now, but i'm really looking for simultaneous keys pressed from all semirows, like from this example: the code below works, it reads from both cursors and 'wsad' keys Code: cls |