# [SOLVED]Keyboard Shortcuts In The Editor

#### Prakhar

It would be better if this website supports more shortcuts like the command \frac{}{} should come with the press of a button inside the MATH environment along with more such latex commands. Also, some who puts an opening bracket will also close the bracket at some time. If he/she does not close, $$\displaystyle \LaTeX$$ will not be rendered properly. So, if someone opens a bracket, the closing bracket should come automatically and the Tab key should switch to the typing area outside the bracket.

If someone types \begin{array }, the \end{array} command should come automatically. Similarly, \end{matrix} should automatically come after typing \begin{matrix}. It would be even better if these two commands come by the press of a button.

#### MarkFL

Staff member
Hello Prakhar!

If you look to the right of the post message editor, you will see our Quick $\LaTeX$ tool. From this tool you can choose from a wide variety of commonly used symbols and commands. We have these symbols/commands grouped by categories which you can choose from the drop-down menu at the top, and then clicking on the icons will insert the appropriate code into the active text area, for example whether you are composing a post, using the $\LaTeX$ Live Preview.

Having closing brackets/commands be automatically generated would be computationally intensive as each keystroke or change to the affected elements would require a parsing of that element's contents. This may be something we consider for a future upgrade of the $\LaTeX$ Live Preview because it is already parsed for each change to the input element. When using the Quick $\LaTeX$ and $\LaTeX$ Live Preview to generate the various codes, the closing codes are automatically generated.

For example, if you click the "Begin/End" button on the $\LaTeX$ Live Preview, you will be guided though the process of creating matrices, piecewise functions, synthetic/polynomial division, and the begin/end statements are automatically generated for you.

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
Speaking about keyboard shortcuts, I would really like a shortcut for the [m] tag similar to shortcuts for [b], [i] and [u]. There should probably also be a button on the toolbar for it, but for me personally having shortcut is more important.

I also suggest making the height of the gray region smaller. Compare StackExchange on the left and MHB on the right.

#### Jameson

Staff member
It would be better if this website supports more shortcuts like the command \frac{}{} should come with the press of a button inside the MATH environment along with more such latex commands. Also, some who puts an opening bracket will also close the bracket at some time. If he/she does not close, $$\displaystyle \LaTeX$$ will not be rendered properly. So, if someone opens a bracket, the closing bracket should come automatically and the Tab key should switch to the typing area outside the bracket.

If someone types \begin{array }, the \end{array} command should come automatically. Similarly, \end{matrix} should automatically come after typing \begin{matrix}. It would be even better if these two commands come by the press of a button.
As Mark said, we already have in place a pretty extensive LaTeX menu that you won't find on many other sites. I really like it and think it works well. We also have a live preview LaTeX renderer so you can test out your code without having to refresh the page. I agree with Mark that the auto close tags would be hard to implement. It's a great idea of course and it's something that happens on overleaf.com for example, which I really like. Luckily the Quick LaTeX menu will close tags if they are opened in the aligned environment.

Speaking about keyboard shortcuts, I would really like a shortcut for the [m] tag similar to shortcuts for [b], [i] and [u]. There should probably also be a button on the toolbar for it, but for me personally having shortcut is more important.

I also suggest making the height of the gray region smaller. Compare StackExchange on the left and MHB on the right.
We can add a button to the toolbar. By a keyboard shortcut, you mean something like Ctr+B (for bold)? That kind of shorcut?

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
By a keyboard shortcut, you mean something like Ctr+B (for bold)?
Yes, say, Ctrl+M for [m].

#### MarkFL

Staff member
As we speak, I am working on adding the Ctrl+M functionality. I have already reduced the height of the gray background, and once I have both done will make the changes to the live site.

#### MarkFL

Staff member
I have decreased the height of the shaded area:

This is an [m]identifier[/m].

I have also added an event listener to the basic and standard editors so that pressing Ctrl-M or Ctrl-m will generate the tags as requested. The WYSIWYG editor seems to have an event handler that will not permit this (perhaps we can add a button on the toolbar if the WYSIWYG editor users desire). You must have either the basic or standard editors defined as your editor in your settings so that the needed element to which the event is attached is in place at the time the page loads.

You will also have to clear your browser cache so that the new version of our editor script file is loaded.

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
Thanks, Mark! Ctrl+M seems to work in the standard editor.

For the gray background, I would still prefer the gap between the top of the box and the top of letters to be smaller. Perhaps the box could be moved down a little so that it is more vertically centered around the highlighted word. But this is not essential. Perhaps we can look at how highlighting is done in other websites and programs, such as text editors.

#### MarkFL

Staff member
Glad to hear it works for you, Evgeny! I am going to continue to work to find a way for this to work in the WYSIWYG editor.

I lightened the gray color a bit and changed the line height attribute instead of manipulating the padding:

Tall letters:

[m]lth[/m]

Short letters:

[m]xxx[/m]

Low-hanging letters:

[m]qyg[/m]

#### MarkFL

Staff member
It turns out I simply did not know how to add an event listener to an element within an inline document (iframe). I know now, and the Ctrl+M keyboard shortcut works with all of our editors.