Current location: Hot Scripts Forums » General Web Coding » JavaScript » Shortcut keys? Superscript/subscript


Shortcut keys? Superscript/subscript

Reply
  #1 (permalink)  
Old 11-13-09, 09:03 AM
mjjwatson mjjwatson is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 26
Thanks: 2
Thanked 1 Time in 1 Post
Shortcut keys? Superscript/subscript

I'm making an application for teachers, where they can input their own question sets and use them in various ways (print off pdfs, run flash apps, etc).

I have had some feedback from the science departments that they want a way to type in superscript and subscript in the question forms.

I'm a little stumped on how to make this happen. I know how to style sub/superscript of course with css, but ideally they could use a shortcut key, like on a wordprocessor, to enter superscript numbers, for example alt+2 when typing in a textfield.

I really don't know where to begin finding out if this is possible. If anyone has any pointers it would be ultra appreciated. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-13-09, 10:39 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
How about using a WYSIWYG input area, like the CKEditor, TinyMCE, Nicedit, or something similar?
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-13-09, 10:53 AM
mjjwatson mjjwatson is offline
Newbie Coder
 
Join Date: Nov 2009
Posts: 26
Thanks: 2
Thanked 1 Time in 1 Post
If I need to, I guess I will, although part of me wants to learn how to do this from scratch. I'm building everything from scratch for this project, which is actually a first for me, (normally I hack away at other people's things or CMSs, etc).

Am I in the right place to assume that javascript is the answer?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-13-09, 11:31 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, JavaScript can be used to catch input events, which is what those editors End User suggested does to do things with shortcuts.

Writing a tutorial for this would take some time, so I'll just point you to some links for now. You can try QuirksMode (link in signature) for a good reference on dealing with events across various browsers. Once you have caught the event and know it's time to insert say
Code:
<span class='redBoldText'></span>
or
Code:
<strong></strong>
around the selected text, you need to get the document's selection. Depending on the browser, t's a call to a method of the window or document object. You might also have to convert that selection to a range object, again depending on the browser. The range/selection object can then be manipulated and wrapped in your tag.

Looking at one of the WYSIWYG editors with less features might be a good idea as you can take ideas from already working code.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i print the primary keys of table in ms access in php code hawkeye000 PHP 6 12-23-08 06:24 AM
Foreign Keys in MySQL and PHP davestar057 PHP 1 02-04-08 07:58 AM
Layout-Compatibillity and scrolling with arrow keys buzznick CSS 4 12-10-06 04:06 AM
SQL primary/foreign keys question ammonkc PHP 2 11-29-05 01:47 AM
MYSQL innoDB recognizing foreign keys cmmourik PHP 1 03-31-05 11:01 AM


All times are GMT -5. The time now is 09:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.