pouët.net

charcode and other such madness (javascript)

category: code [glöplog]
 
Is there an internal way to convert charcode+modifiers to a proper character? I'm not fancying this String.fromCharCode(e.keyCode || e.charCode) indexing a lookup table technique.
added on the 2013-11-06 00:34:05 by sigflup sigflup
that is indexing a lookup table based on modifiers....
added on the 2013-11-06 00:34:57 by sigflup sigflup
I wish. Alas there is no way to get the character from a keypress including the consumed modifiers and dead keys. This gap in the specs makes it impossible to make a serious app with keyboard navigation/input/shortcuts. You're left with hacking around.

Which modifiers to want/need to support ?
added on the 2013-11-06 00:51:06 by p01 p01
s/to/do you
added on the 2013-11-06 00:51:33 by p01 p01
Aww, nuts. I trust you p01. you're javascript fu is strong. Just the shift modifier, I can use my table.
added on the 2013-11-06 01:30:52 by sigflup sigflup
your
added on the 2013-11-06 01:32:30 by sigflup sigflup
Here is an example for keyboard events (focus the edit field and hit any key on your keyboard):
http://www.mediaevent.de/javascript/Extras-Javascript-Keycodes.html
added on the 2013-11-06 04:03:54 by Salinga Salinga
Another paper on this:
http://unixpapa.com/js/key.html
added on the 2013-11-06 04:07:22 by Salinga Salinga
Here is a keypress library for JavaScript (has a nice demo keyboard on the page, showing the keys pressed):
http://dmauro.github.io/Keypress/
added on the 2013-11-06 04:08:56 by Salinga Salinga
String.fromCharCode(e.keyCode || e.charCode) - wut? Why not just String.fromCharCode(e.which) ?
added on the 2013-11-06 05:16:08 by Suborg Suborg
Ain´t this sorted in a standard byteArray anymore?
By first asking if shift (let it be $fe) is inputted, then asking what other key is inputted, you should get what you need, right? did they really complicate it? i guess i know why i dont want to code such stuff now, its just unnormal! ;)
Well, in other news i didnt want to post in here anymore! :( but i have to, because it´s normal to answer on such stuff!
Bye then! :D
PS: i am still into amiga-ascii...where Space equals $20 and from there you get numbers followed by a-z, followed by special characters !"§$%/(/( )&(/§%$%²³ dollowed by A-Z etc...all fitting into 256! ;) So for SHIFTed (uppercase) letters you´d just add some amount to your byte and be done!
ok, you get them as Strings instead of char* , i see...cant you just decimate your string down to one single letter and from there convert it to "char", which is equivalent to "byte", so you know where you´re at again?
hardy: Remember that all this web stuff must work for all keyboard layouts and languages ( UNICODE baby ). It's a bit more complex than working with a couple of pages of lower ASCII characters ( <128 ) . Just to give you an idea, many languages have a single case ( no uppercase & lowercase, it's just one case ), have their own punctuations, have far more glyphs than available on a regular keyboard thus the user had to type 2-3 characters ( which of course are registered and displayed as individual key inputs) which are THEN transformed into a single glyph by the OS. Key handling and i18n is a wonderful and colorful world.

Good luck building a web app with keyboard shortcuts and that catches all this things correctly.

Now, of course you're free to make your app only available in English and support English keyboard layout ( Hello! EN_US and EN_GB layouts ), in which case you can take some shortcuts ( See what I did there :p ) in your key handling.
added on the 2013-11-06 11:32:19 by p01 p01
yep, i knew its about codetables and ISO-XX, just deleted that part after realizing it would make my answers even more hard to read/understanable/followable! I just still hoped for some easy solution ;) i am not into web tho, just tried to make it as easy as possible to other people or the threadstarter to find a working solution at all! :)
well, to me web2.0 is stuck in the 90s, eventho just NEW and thats not only thanks to the limitations, but also thanks to no1 really wants to use it graphics-wise, except us demosceners, whom are open up to everthing new ofcoz! ...well...i dont think we have to grow back but on!
Sorry, but to me this all sucks! if someone wants to learn coding, heshe can go easy roads or just the correct way! all of this web-code is 100% lamer to me! not coewise, but outcome-wise! there are superb web-demos by alcatraz and scoopex and others, but its all that far away from the roots! sometimes i think a monkey could do that, but i am certainly true it aint like that ofcoz! still lots of steps back if you can use NEW tech! and i am saying that while i am oldskooling wherever i can, i hate all of that OO-stuff, while using it almost in every routine i do nowadays! hard to tell, but distracts me the most, but i think its worthless to try to get into it, while everyone else says its the future! if it´s really the future, why the FunkyHomoSapien i´ve been there already? several times, 10 years ago?!!
Sorry, had to!
hArDy: Actually, Unicode is the modern alternative to the whole codepage-mess.
added on the 2013-11-06 12:26:14 by kusma kusma
I havent been thru the codepage.mess at all ;) juat read about it later!
Been on a REAL computer until 2005! AMIGA 1200!
It shows.
added on the 2013-11-06 13:00:25 by Gargaj Gargaj
[offtopic]
hardy: Diff'rent Strokes. The are room for all kinds of people, languages and platforms. I certainly appreciate web stuffs, old & new school tech attack. The thing I like about the web, despite the quirks, is the ubiquity and accessibility of the platform. But again, diff'rent strokes. Sorry, but may I ask if you code for a living or do you only code for fun ?
[/offtopic]
added on the 2013-11-06 13:08:57 by p01 p01
Quote:
i am not into web tho
meaning "I have no clue what I'm talking about."
Quote:
make it as easy as possible to other people or the threadstarter to find a working solution at all
meaning "I'll just troll around saying how stupid coding is nowadays".
added on the 2013-11-06 15:35:38 by xTr1m xTr1m
Quote:
well, to me web2.0 is stuck in the 90s

...
Quote:
Sorry, but to me this all sucks! if someone wants to learn coding, heshe can go easy roads or just the correct way! all of this web-code is 100% lamer to me!


I think that mindset is more stuck in the 90's than anything else :)
added on the 2013-11-06 16:26:00 by ferris ferris
is it hardy bashing season again? how about keeping things on topic? just a thought.
added on the 2013-11-06 16:57:43 by psenough psenough
its ok, ps, thanks though!
its ok, because this time i really just trolled around! :D
xTr1m nailed it down! :)

login