# New block

I need a block that reports the last key pressed.
I already know how to make a block that reports the keys pressed, but not the last key pressed.
if it is possible please let me know!

I already know how to make a block that reports the keys pressed

In that case, you're making it seem much more complicated than it is.
[scratchblocks](item (last v) of (keys pressed::sensing)[/scratchblocks]

This is an interesting ambiguity in English. By "the keys pressed" he means pressed right now; the "-ed" ending is for the passive voice, not the past tense. Whereas in "last key pressed" the "-ed" does mean past tense.

One solution would be this:

But that would really annoying it'd be really long if you wanted detect for every key, and it's just the same pattern of blocks except two inputs has changed.

Another one would be this:

oh what-- oh that's why it took longer than expected to upload i tried pasting the script pic even though it doesn't save it to my clipboard

i mean this

but you would have to construct a list of all the key names

Or, if you don't want to show the input to the user, you can use this JavaScript solution:

if you want to show the input to the user you would probably want to convert each code (they go something like "KeyA", "KeyB", "ShiftLeft") to more simpler names. you would probably do this by constructing a dictionary/assoc list for every key, but you would make twice more items than if you used the previous solution

you can do that programmatically with this script

note: I did it all in the order they appear in, in the keys dropdown menu.

There is one flaw with this script, it doesn't get the translations for different languages.

Shouldnt u delete that?

I think it's probably partially for humor

A moment of humor in a mostly on-topic post isn't a problem (supposing the humor isn't insulting someone, or racist, etc.).

well I already have a list!

 1234567890-=~!@#\$%^&*()_+¡™£¢∞§¶•ªº–≠⁄€‹›ﬁﬂ‡°·‚—±qwertyuiop[]\asdfghjkl;'zxcvbnm,./œ∑´®†¥¨ˆøπ“‘«åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤≥÷Œ„´‰ˇÁ¨ˆØ∏”’»ÅÍÎÏ˝ÓÔÒÚÆ¸˛Ç◊ı˜Â¯˘¿{}|:"<>? 

and then I use append to add the other keys

One of my two questions that this thread has raised is whether it is OK that the menu for key ... pressed?` doesn't include Unicode or non-English characters (maybe because of my language setting?)

My other question is whether it is possible that the following could miss a key press

If the press was very quick and there were lots of computations competing with it? Can't the press be over by the time these blocks are run?

I think it's right that the menu shouldn't be huge; I'd be happier if we could special-case a two-dimensional key menu. But because the menu is restricted, you should be able to paste any Unicode character into that slot. (In the hat block too.)

Yes, I imagine so. Why wouldn't you just use the "key pressed" hat block?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.