%Teilweise Erzeugt mit dem LaTeX-Generator: http://latex.sehnot.de

%Schriftgröße, Layout, Papierformat, Art des Dokumentes
\documentclass[10pt,oneside,a4paper]{scrartcl}

%Einstellungen der Seitenränder
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=1.5cm,includeheadfoot]{geometry}

%neue Rechtschreibung
\usepackage[ngerman]{babel}

%Umlaute ermöglichen
\usepackage[utf8]{inputenc}

%Gesamtseitenzahl
\usepackage{lastpage}

% Kopf- und Fußzeile
\usepackage[automark]{scrpage2}

%Quellcode-Listings
\usepackage{listings}

%Hyperlinks
\usepackage{hyperref}

\usepackage{listings}
\usepackage{color}
\definecolor{lightgray}{rgb}{.9,.9,.9}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}

\lstdefinelanguage{JavaScript}{
  keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
  keywordstyle=\color{blue}\bfseries,
  ndkeywords={class, export, boolean, throw, implements, import, this},
  ndkeywordstyle=\color{darkgray}\bfseries,
  identifierstyle=\color{black},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  commentstyle=\color{purple}\ttfamily,
  stringstyle=\color{red}\ttfamily,
  morestring=[b]',
  morestring=[b]"
}

\lstset{
   language=JavaScript,
   backgroundcolor=\color{lightgray},
   extendedchars=true,
   basicstyle=\footnotesize\ttfamily,
   showstringspaces=false,
   showspaces=false,   
   tabsize=2,
   breaklines=true,
   showtabs=false,
   captionpos=b
}

%Kopfzeile
\ihead{JavaScript}
\chead{}
\ohead{http://kohnlehome.de/html/javascript-events.pdf}
\setheadsepline{0.5pt}

%Fußzeile
\setfootsepline{0.5pt}
\ifoot{Franz Kohnle}
\cfoot{Seite \thepage\ von  \pageref{LastPage}}
\ofoot{\today}

\pagestyle{scrheadings}


\begin{document}
% Überschrift 
\begin{center}
\LARGE % Schriftgröße
\bfseries % Fettdruck
\sffamily % Serifenlose Schrift
JavaScript-Events
\end{center}

\section{Als HTML-Attribut}
HTML:
\begin{lstlisting}[]
<element onclick="tuwas()">
\end{lstlisting}
JavaScript:
\begin{lstlisting}[]
function tuwas(event){
	...
}
\end{lstlisting}


\section{Als Objekteigenschaft}
HTML:
\begin{lstlisting}[]
<element id="xyz">
\end{lstlisting}
JavaScript:
\begin{lstlisting}[]
var objekt = document.getElementById("xyz");
objekt.onclick = tuwas;
\end{lstlisting}

\begin{lstlisting}[]
function tuwas(event){
	...
}
\end{lstlisting}

\section{Mit Eventlistener}
HTML:
\begin{lstlisting}[]
<element id="xyz">
\end{lstlisting}
JavaScript:
\begin{lstlisting}[]
var objekt = document.getElementById("xyz");
objekt.addEventListener('click', tuwas, false);
\end{lstlisting}

\begin{lstlisting}[]
function tuwas(event){
	...
}
\end{lstlisting}


\section{Events}
\subsection{Maus}
mousedown, mouseup, click, mouseover, mousemove, mouseout
\subsection{Tastatur}
keydown, keypress, keyup


\section{Das event-Objekt}

\section{Timer}
starten:
\begin{lstlisting}[]
var id = setInterval("tuwas()", 100); // Zeit in ms
\end{lstlisting}
stoppen:
\begin{lstlisting}[]
clearInterval(id);
\end{lstlisting}


\end{document}